Skip to content

Commit 5afe2b2

Browse files
authored
Merge pull request #754 from python-babel/github-ci
CI: Switch to GitHub Actions
2 parents 9f6ea69 + 58de834 commit 5afe2b2

File tree

13 files changed

+92
-236
lines changed

13 files changed

+92
-236
lines changed

.ci/appveyor.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.ci/deploy.linux.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

.ci/deploy.osx.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

.ci/deps.linux.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

.ci/deps.osx.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

.ci/run_with_env.cmd

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-18.04, windows-2019, macos-10.15]
15+
python-version: [3.6, 3.7, 3.8, 3.9, pypy3]
16+
exclude:
17+
- os: windows-2019
18+
python-version: pypy3
19+
# TODO: Remove this; see:
20+
# https://github.com/actions/setup-python/issues/151
21+
# https://github.com/tox-dev/tox/issues/1704
22+
# https://foss.heptapod.net/pypy/pypy/-/issues/3331
23+
env:
24+
BABEL_CLDR_NO_DOWNLOAD_PROGRESS: "1"
25+
BABEL_CLDR_QUIET: "1"
26+
steps:
27+
- uses: actions/checkout@v2
28+
- name: Set up Python ${{ matrix.python-version }}
29+
uses: actions/setup-python@v2
30+
with:
31+
python-version: ${{ matrix.python-version }}
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip setuptools wheel
35+
python -m pip install tox tox-gh-actions==2.1.0
36+
- name: Run test via Tox
37+
run: tox --skip-missing-interpreters
38+
- uses: codecov/codecov-action@v1

.travis.yml

Lines changed: 0 additions & 74 deletions
This file was deleted.

scripts/download_import_cldr.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,13 @@ def main():
7575
cldr_path = os.path.join(repo, 'cldr', os.path.splitext(FILENAME)[0])
7676
zip_path = os.path.join(cldr_dl_path, FILENAME)
7777
changed = False
78+
show_progress = (False if os.environ.get("BABEL_CLDR_NO_DOWNLOAD_PROGRESS") else sys.stdout.isatty())
7879

7980
while not is_good_file(zip_path):
8081
log('Downloading \'%s\'', FILENAME)
8182
if os.path.isfile(zip_path):
8283
os.remove(zip_path)
83-
urlretrieve(URL, zip_path, reporthook)
84+
urlretrieve(URL, zip_path, (reporthook if show_progress else None))
8485
changed = True
8586
print()
8687
common_path = os.path.join(cldr_path, 'common')

scripts/import_cldr.py

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import os
1818
import re
1919
import sys
20+
import logging
2021

2122
try:
2223
from xml.etree import cElementTree as ElementTree
@@ -62,16 +63,7 @@ def _text(elem):
6263
'timeFormats': 'time_formats'
6364
}
6465

65-
66-
def log(message, *args):
67-
if args:
68-
message = message % args
69-
sys.stderr.write(message + '\r\n')
70-
sys.stderr.flush()
71-
72-
73-
def error(message, *args):
74-
log('ERROR: %s' % message, *args)
66+
log = logging.getLogger("import_cldr")
7567

7668

7769
def need_conversion(dst_filename, data_dict, source_filename):
@@ -182,10 +174,19 @@ def main():
182174
'-j', '--json', dest='dump_json', action='store_true', default=False,
183175
help='also export debugging JSON dumps of locale data'
184176
)
177+
parser.add_option(
178+
'-q', '--quiet', dest='quiet', action='store_true', default=bool(os.environ.get('BABEL_CLDR_QUIET')),
179+
help='quiesce info/warning messages',
180+
)
185181

186182
options, args = parser.parse_args()
187183
if len(args) != 1:
188184
parser.error('incorrect number of arguments')
185+
186+
logging.basicConfig(
187+
level=(logging.ERROR if options.quiet else logging.INFO),
188+
)
189+
189190
return process_data(
190191
srcdir=args[0],
191192
destdir=BABEL_PACKAGE_ROOT,
@@ -383,15 +384,18 @@ def _process_local_datas(sup, srcdir, destdir, force=False, dump_json=False):
383384
territory = '001' # world
384385
regions = territory_containment.get(territory, [])
385386

386-
log('Processing %s (Language = %s; Territory = %s)',
387-
filename, language, territory)
387+
log.info(
388+
'Processing %s (Language = %s; Territory = %s)',
389+
filename, language, territory,
390+
)
388391

389392
locale_id = '_'.join(filter(None, [
390393
language,
391394
territory != '001' and territory or None
392395
]))
393396

394397
data['locale_id'] = locale_id
398+
data['unsupported_number_systems'] = set()
395399

396400
if locale_id in plural_rules:
397401
data['plural_form'] = plural_rules[locale_id]
@@ -432,6 +436,13 @@ def _process_local_datas(sup, srcdir, destdir, force=False, dump_json=False):
432436
parse_character_order(data, tree)
433437
parse_measurement_systems(data, tree)
434438

439+
unsupported_number_systems_string = ', '.join(sorted(data.pop('unsupported_number_systems')))
440+
if unsupported_number_systems_string:
441+
log.warning('%s: unsupported number systems were ignored: %s' % (
442+
locale_id,
443+
unsupported_number_systems_string,
444+
))
445+
435446
write_datafile(data_filename, data, dump_json=dump_json)
436447

437448

@@ -440,21 +451,14 @@ def _should_skip_number_elem(data, elem):
440451
Figure out whether the numbering-containing element `elem` is in a currently
441452
non-supported (i.e. currently non-Latin) numbering system.
442453
443-
If it is, a warning is raised.
444-
445-
:param data: The root data element, for formatting the warning.
454+
:param data: The root data element, for stashing the warning.
446455
:param elem: Element with `numberSystem` key
447456
:return: Boolean
448457
"""
449458
number_system = elem.get('numberSystem', 'latn')
450459

451460
if number_system != 'latn':
452-
log('%s: Unsupported number system "%s" in <%s numberSystem="%s">' % (
453-
data['locale_id'],
454-
number_system,
455-
elem.tag,
456-
number_system,
457-
))
461+
data['unsupported_number_systems'].add(number_system)
458462
return True
459463

460464
return False
@@ -686,7 +690,7 @@ def parse_calendar_date_formats(data, calendar):
686690
text_type(elem.findtext('dateFormat/pattern'))
687691
)
688692
except ValueError as e:
689-
error(e)
693+
log.error(e)
690694
elif elem.tag == 'alias':
691695
date_formats = Alias(_translate_alias(
692696
['date_formats'], elem.attrib['path'])
@@ -706,7 +710,7 @@ def parse_calendar_time_formats(data, calendar):
706710
text_type(elem.findtext('timeFormat/pattern'))
707711
)
708712
except ValueError as e:
709-
error(e)
713+
log.error(e)
710714
elif elem.tag == 'alias':
711715
time_formats = Alias(_translate_alias(
712716
['time_formats'], elem.attrib['path'])
@@ -725,7 +729,7 @@ def parse_calendar_datetime_skeletons(data, calendar):
725729
try:
726730
datetime_formats[type] = text_type(elem.findtext('dateTimeFormat/pattern'))
727731
except ValueError as e:
728-
error(e)
732+
log.error(e)
729733
elif elem.tag == 'alias':
730734
datetime_formats = Alias(_translate_alias(
731735
['datetime_formats'], elem.attrib['path'])

setup.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,16 @@ def run(self):
4444
'License :: OSI Approved :: BSD License',
4545
'Operating System :: OS Independent',
4646
'Programming Language :: Python',
47-
'Programming Language :: Python :: 2',
48-
'Programming Language :: Python :: 2.7',
4947
'Programming Language :: Python :: 3',
50-
'Programming Language :: Python :: 3.4',
51-
'Programming Language :: Python :: 3.5',
5248
'Programming Language :: Python :: 3.6',
5349
'Programming Language :: Python :: 3.7',
50+
'Programming Language :: Python :: 3.8',
51+
'Programming Language :: Python :: 3.9',
5452
'Programming Language :: Python :: Implementation :: CPython',
5553
'Programming Language :: Python :: Implementation :: PyPy',
5654
'Topic :: Software Development :: Libraries :: Python Modules',
5755
],
58-
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
56+
python_requires='>=3.6',
5957
packages=['babel', 'babel.messages', 'babel.localtime'],
6058
include_package_data=True,
6159
install_requires=[

0 commit comments

Comments
 (0)