Skip to content

Commit

Permalink
Python 3.10 (#1868)
Browse files Browse the repository at this point in the history
* Add Py 3.10 #1866

* Add tests for Python 3.10

* update Babelfish
  • Loading branch information
clinton-hall authored Dec 3, 2021
1 parent 684cab5 commit 686d239
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 387 deletions.
4 changes: 3 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ jobs:
python.version: '3.8'
Python39:
python.version: '3.9'
maxParallel: 5
Python310:
python.version: '3.10'
maxParallel: 3

steps:
- script: |
Expand Down
1 change: 1 addition & 0 deletions eol.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def date(string, fmt='%Y-%m-%d'):
# https://devguide.python.org/
# https://devguide.python.org/devcycle/#devcycle
PYTHON_EOL = {
(3, 10): date('2026-10-01'),
(3, 9): date('2025-10-05'),
(3, 8): date('2024-10-14'),
(3, 7): date('2023-06-27'),
Expand Down
6 changes: 0 additions & 6 deletions libs/common/babelfish/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
# Use of this source code is governed by the 3-clause BSD license
# that can be found in the LICENSE file.
#
__title__ = 'babelfish'
__version__ = '0.5.5-dev'
__author__ = 'Antoine Bertin'
__license__ = 'BSD'
__copyright__ = 'Copyright 2015 the BabelFish authors'

import sys

if sys.version_info[0] >= 3:
Expand Down
13 changes: 9 additions & 4 deletions libs/common/babelfish/converters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@
# Use of this source code is governed by the 3-clause BSD license
# that can be found in the LICENSE file.
#
import collections
from pkg_resources import iter_entry_points, EntryPoint
from ..exceptions import LanguageConvertError, LanguageReverseError

try:
# Python 3.3+
from collections.abc import Mapping, MutableMapping
except ImportError:
from collections import Mapping, MutableMapping


# from https://github.com/kennethreitz/requests/blob/master/requests/structures.py
class CaseInsensitiveDict(collections.MutableMapping):
class CaseInsensitiveDict(MutableMapping):
"""A case-insensitive ``dict``-like object.
Implements all methods and operations of
``collections.MutableMapping`` as well as dict's ``copy``. Also
``collections.abc.MutableMapping`` as well as dict's ``copy``. Also
provides ``lower_items``.
All keys are expected to be strings. The structure remembers the
Expand Down Expand Up @@ -63,7 +68,7 @@ def lower_items(self):
)

def __eq__(self, other):
if isinstance(other, collections.Mapping):
if isinstance(other, Mapping):
other = CaseInsensitiveDict(other)
else:
return NotImplemented
Expand Down
6 changes: 3 additions & 3 deletions libs/common/babelfish/converters/opensubtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class OpenSubtitlesConverter(LanguageReverseConverter):
def __init__(self):
self.alpha3b_converter = language_converters['alpha3b']
self.alpha2_converter = language_converters['alpha2']
self.to_opensubtitles = {('por', 'BR'): 'pob', ('gre', None): 'ell', ('srp', None): 'scc', ('srp', 'ME'): 'mne'}
self.to_opensubtitles = {('por', 'BR'): 'pob', ('gre', None): 'ell', ('srp', None): 'scc', ('srp', 'ME'): 'mne', ('chi', 'TW'): 'zht'}
self.from_opensubtitles = CaseInsensitiveDict({'pob': ('por', 'BR'), 'pb': ('por', 'BR'), 'ell': ('ell', None),
'scc': ('srp', None), 'mne': ('srp', 'ME')})
self.codes = (self.alpha2_converter.codes | self.alpha3b_converter.codes | set(['pob', 'pb', 'scc', 'mne']))
'scc': ('srp', None), 'mne': ('srp', 'ME'), 'zht': ('zho', 'TW')})
self.codes = (self.alpha2_converter.codes | self.alpha3b_converter.codes | set(self.from_opensubtitles.keys()))

def convert(self, alpha3, country=None, script=None):
alpha3b = self.alpha3b_converter.convert(alpha3, country, script)
Expand Down
Loading

0 comments on commit 686d239

Please sign in to comment.