Skip to content

Commit

Permalink
Merge pull request #754 from python-babel/github-ci
Browse files Browse the repository at this point in the history
CI: Switch to GitHub Actions
  • Loading branch information
akx committed Dec 4, 2020
2 parents 9f6ea69 + 58de834 commit 5afe2b2
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 236 deletions.
38 changes: 0 additions & 38 deletions .ci/appveyor.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .ci/deploy.linux.sh

This file was deleted.

4 changes: 0 additions & 4 deletions .ci/deploy.osx.sh

This file was deleted.

4 changes: 0 additions & 4 deletions .ci/deps.linux.sh

This file was deleted.

11 changes: 0 additions & 11 deletions .ci/deps.osx.sh

This file was deleted.

47 changes: 0 additions & 47 deletions .ci/run_with_env.cmd

This file was deleted.

38 changes: 38 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,38 @@
name: Test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, windows-2019, macos-10.15]
python-version: [3.6, 3.7, 3.8, 3.9, pypy3]
exclude:
- os: windows-2019
python-version: pypy3
# TODO: Remove this; see:
# https://github.com/actions/setup-python/issues/151
# https://github.com/tox-dev/tox/issues/1704
# https://foss.heptapod.net/pypy/pypy/-/issues/3331
env:
BABEL_CLDR_NO_DOWNLOAD_PROGRESS: "1"
BABEL_CLDR_QUIET: "1"
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install tox tox-gh-actions==2.1.0
- name: Run test via Tox
run: tox --skip-missing-interpreters
- uses: codecov/codecov-action@v1
74 changes: 0 additions & 74 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion scripts/download_import_cldr.py
Expand Up @@ -75,12 +75,13 @@ def main():
cldr_path = os.path.join(repo, 'cldr', os.path.splitext(FILENAME)[0])
zip_path = os.path.join(cldr_dl_path, FILENAME)
changed = False
show_progress = (False if os.environ.get("BABEL_CLDR_NO_DOWNLOAD_PROGRESS") else sys.stdout.isatty())

while not is_good_file(zip_path):
log('Downloading \'%s\'', FILENAME)
if os.path.isfile(zip_path):
os.remove(zip_path)
urlretrieve(URL, zip_path, reporthook)
urlretrieve(URL, zip_path, (reporthook if show_progress else None))
changed = True
print()
common_path = os.path.join(cldr_path, 'common')
Expand Down
52 changes: 28 additions & 24 deletions scripts/import_cldr.py
Expand Up @@ -17,6 +17,7 @@
import os
import re
import sys
import logging

try:
from xml.etree import cElementTree as ElementTree
Expand Down Expand Up @@ -62,16 +63,7 @@ def _text(elem):
'timeFormats': 'time_formats'
}


def log(message, *args):
if args:
message = message % args
sys.stderr.write(message + '\r\n')
sys.stderr.flush()


def error(message, *args):
log('ERROR: %s' % message, *args)
log = logging.getLogger("import_cldr")


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

options, args = parser.parse_args()
if len(args) != 1:
parser.error('incorrect number of arguments')

logging.basicConfig(
level=(logging.ERROR if options.quiet else logging.INFO),
)

return process_data(
srcdir=args[0],
destdir=BABEL_PACKAGE_ROOT,
Expand Down Expand Up @@ -383,15 +384,18 @@ def _process_local_datas(sup, srcdir, destdir, force=False, dump_json=False):
territory = '001' # world
regions = territory_containment.get(territory, [])

log('Processing %s (Language = %s; Territory = %s)',
filename, language, territory)
log.info(
'Processing %s (Language = %s; Territory = %s)',
filename, language, territory,
)

locale_id = '_'.join(filter(None, [
language,
territory != '001' and territory or None
]))

data['locale_id'] = locale_id
data['unsupported_number_systems'] = set()

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

unsupported_number_systems_string = ', '.join(sorted(data.pop('unsupported_number_systems')))
if unsupported_number_systems_string:
log.warning('%s: unsupported number systems were ignored: %s' % (
locale_id,
unsupported_number_systems_string,
))

write_datafile(data_filename, data, dump_json=dump_json)


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

if number_system != 'latn':
log('%s: Unsupported number system "%s" in <%s numberSystem="%s">' % (
data['locale_id'],
number_system,
elem.tag,
number_system,
))
data['unsupported_number_systems'].add(number_system)
return True

return False
Expand Down Expand Up @@ -686,7 +690,7 @@ def parse_calendar_date_formats(data, calendar):
text_type(elem.findtext('dateFormat/pattern'))
)
except ValueError as e:
error(e)
log.error(e)
elif elem.tag == 'alias':
date_formats = Alias(_translate_alias(
['date_formats'], elem.attrib['path'])
Expand All @@ -706,7 +710,7 @@ def parse_calendar_time_formats(data, calendar):
text_type(elem.findtext('timeFormat/pattern'))
)
except ValueError as e:
error(e)
log.error(e)
elif elem.tag == 'alias':
time_formats = Alias(_translate_alias(
['time_formats'], elem.attrib['path'])
Expand All @@ -725,7 +729,7 @@ def parse_calendar_datetime_skeletons(data, calendar):
try:
datetime_formats[type] = text_type(elem.findtext('dateTimeFormat/pattern'))
except ValueError as e:
error(e)
log.error(e)
elif elem.tag == 'alias':
datetime_formats = Alias(_translate_alias(
['datetime_formats'], elem.attrib['path'])
Expand Down
8 changes: 3 additions & 5 deletions setup.py
Expand Up @@ -44,18 +44,16 @@ def run(self):
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Software Development :: Libraries :: Python Modules',
],
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
python_requires='>=3.6',
packages=['babel', 'babel.messages', 'babel.localtime'],
include_package_data=True,
install_requires=[
Expand Down

0 comments on commit 5afe2b2

Please sign in to comment.