diff options
-rw-r--r-- | CHANGES.rst | 8 | ||||
-rw-r--r-- | setup.py | 3 | ||||
-rw-r--r-- | src/zope/i18n/locales/inheritance.py | 28 |
3 files changed, 28 insertions, 11 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index 265f7a2..6754958 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,7 +2,7 @@ CHANGES ========= -4.2.1 (unreleased) +4.3.0 (unreleased) ================== - Ensure that all files are properly closed when compiling .mo files, @@ -24,7 +24,11 @@ KeyError when the ``week`` mapping contained an integer for ``firstDay`` as documented. -- Reach 100% test coverage and maintain in through tox.ini and coveralls.io. +- Reach 100% test coverage and maintain in through tox.ini and + coveralls.io. + +- Override ``values`` in ``InheritingDictionary``. Previously it + implemented a separate ``value`` method by mistake. - Fix parsing times with a timezone. Previously it could raise a ``TypeError``. @@ -59,7 +59,7 @@ TESTS_REQUIRE = COMPILE_REQUIRES + ZCML_REQUIRES + [ setup( name='zope.i18n', - version='4.2.1.dev0', + version='4.3.0.dev0', author='Zope Foundation and Contributors', author_email='zope-dev@zope.org', description='Zope Internationalization Support', @@ -98,6 +98,7 @@ setup( 'setuptools', 'python-gettext', 'pytz', + 'zope.deprecation', 'zope.schema', 'zope.i18nmessageid', 'zope.component', diff --git a/src/zope/i18n/locales/inheritance.py b/src/zope/i18n/locales/inheritance.py index 62c99dc..912d8c9 100644 --- a/src/zope/i18n/locales/inheritance.py +++ b/src/zope/i18n/locales/inheritance.py @@ -20,6 +20,8 @@ locale inheritance is not inheritance in the programming sense. """ __docformat__ = 'restructuredtext' +from zope.deprecation import deprecate + from zope.interface import implementer from zope.i18n.interfaces.locales import \ ILocaleInheritance, IAttributeInheritance, IDictionaryInheritance @@ -166,7 +168,7 @@ class InheritingDictionary(Inheritance, dict): >>> locale.data2.dict[2] 'ii' - We also have to overwrite 'get()', 'keys()' and 'items()' since we want + We also have to overwrite `get`, `keys` and `items` since we want to make sure that all upper locales are consulted before returning the default or to construct the list of elements, respectively:: @@ -174,16 +176,25 @@ class InheritingDictionary(Inheritance, dict): 'ii' >>> locale.data2.dict.get(4) is None True - >>> locale.data.keys() + >>> sorted(locale.data.keys()) [1, 2, 3] - >>> list(locale.data.items()) + >>> sorted(locale.data.items()) [(1, 'eins'), (2, 'two'), (3, 'three')] - We currently fail to override ``values``, but instead inherited - data can be seen in the ``value`` method:: + We also override `values`:: - >>> sorted(locale.data.value()) + >>> sorted(locale.data.values()) ['eins', 'three', 'two'] + + Historically, `value` was a synonym of this method; it is still + available, but is deprecated:: + + >>> import warnings + >>> with warnings.catch_warnings(record=True) as w: + ... sorted(locale.data.value()) + ['eins', 'three', 'two'] + >>> print(w[0].message) + `value` is a deprecated synonym for `values` """ @@ -226,6 +237,7 @@ class InheritingDictionary(Inheritance, dict): def keys(self): return list(self._make_reified_inherited_dict().keys()) - def value(self): - # XXX: Was this meant to override values() and is just a typo? + def values(self): return list(self._make_reified_inherited_dict().values()) + + value = deprecate("`value` is a deprecated synonym for `values`")(values) |