diff options
author | Tres Seaver <tseaver@palladion.com> | 2012-05-17 21:50:32 +0000 |
---|---|---|
committer | Tres Seaver <tseaver@palladion.com> | 2012-05-17 21:50:32 +0000 |
commit | cb484dd27562b503beb1362f917d436af717f4eb (patch) | |
tree | 266b07b8b4ad0b09c9349edadc9a788831232109 | |
parent | ccbdea77d5428599ffa03bfdf08b7bf23da150de (diff) | |
download | zope-i18n-cb484dd27562b503beb1362f917d436af717f4eb.tar.gz |
- Drop support for Python 2.4 and 2.5.
- Replace deprecated 'zope.interface.implements' usage with equivalent
'zope.interface.implementer' decorator.
-rw-r--r-- | CHANGES.txt | 7 | ||||
-rw-r--r-- | setup.py | 5 | ||||
-rw-r--r-- | src/zope/i18n/__init__.py | 4 | ||||
-rw-r--r-- | src/zope/i18n/format.py | 6 | ||||
-rw-r--r-- | src/zope/i18n/gettextmessagecatalog.py | 4 | ||||
-rw-r--r-- | src/zope/i18n/locales/__init__.py | 32 | ||||
-rw-r--r-- | src/zope/i18n/locales/inheritance.py | 8 | ||||
-rw-r--r-- | src/zope/i18n/locales/provider.py | 4 | ||||
-rw-r--r-- | src/zope/i18n/negotiator.py | 4 | ||||
-rw-r--r-- | src/zope/i18n/simpletranslationdomain.py | 4 | ||||
-rw-r--r-- | src/zope/i18n/testmessagecatalog.py | 4 | ||||
-rw-r--r-- | src/zope/i18n/tests/test_itranslationdomain.py | 4 | ||||
-rw-r--r-- | src/zope/i18n/tests/test_negotiator.py | 4 | ||||
-rw-r--r-- | src/zope/i18n/tests/testi18nawareobject.py | 5 |
14 files changed, 49 insertions, 46 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 9632ce6..8c6f4e2 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,10 +2,13 @@ CHANGES ======= -3.8.1 (unreleased) +4.0.0 (unreleased) ------------------ -- Nothing changed yet. +- Replaced deprecated ``zope.interface.implements`` usage with equivalent + ``zope.interface.implementer`` decorator. + +- Dropped support for Python 2.4 and 2.5. 3.8.0 (2012-03-15) @@ -27,7 +27,7 @@ def read(*rnames): setup( name='zope.i18n', - version='3.8.1dev', + version='4.0.0dev', author='Zope Foundation and Contributors', author_email='zope-dev@zope.org', description='Zope Internationalization Support', @@ -45,6 +45,9 @@ setup( 'Intended Audience :: Developers', 'License :: OSI Approved :: Zope Public License', 'Programming Language :: Python', + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.6", + "Programming Language :: Python :: 2.7", 'Natural Language :: English', 'Operating System :: OS Independent', 'Topic :: Internet :: WWW/HTTP', diff --git a/src/zope/i18n/__init__.py b/src/zope/i18n/__init__.py index 7c3cc49..aeb1c91 100644 --- a/src/zope/i18n/__init__.py +++ b/src/zope/i18n/__init__.py @@ -53,8 +53,8 @@ def translate(msgid, domain=None, mapping=None, context=None, >>> from zope import component, interface >>> import zope.i18n.interfaces - >>> class TestDomain: - ... interface.implements(zope.i18n.interfaces.ITranslationDomain) + >>> @interface.implementer(zope.i18n.interfaces.ITranslationDomain) + ... class TestDomain: ... ... def __init__(self, **catalog): ... self.catalog = catalog diff --git a/src/zope/i18n/format.py b/src/zope/i18n/format.py index 469e82d..101bd7e 100644 --- a/src/zope/i18n/format.py +++ b/src/zope/i18n/format.py @@ -23,7 +23,7 @@ import pytz import pytz.reference from zope.i18n.interfaces import IDateTimeFormat, INumberFormat -from zope.interface import implements +from zope.interface import implementer def _findFormattingCharacterInPattern(char, pattern): @@ -33,10 +33,10 @@ def _findFormattingCharacterInPattern(char, pattern): class DateTimeParseError(Exception): """Error is raised when parsing of datetime failed.""" +@implementer(IDateTimeFormat) class DateTimeFormat(object): __doc__ = IDateTimeFormat.__doc__ - implements(IDateTimeFormat) _DATETIMECHARS = "aGyMdEDFwWhHmsSkKz" @@ -199,10 +199,10 @@ class NumberParseError(Exception): number parsing process.""" +@implementer(INumberFormat) class NumberFormat(object): __doc__ = INumberFormat.__doc__ - implements(INumberFormat) type = None diff --git a/src/zope/i18n/gettextmessagecatalog.py b/src/zope/i18n/gettextmessagecatalog.py index f8e70a8..b121298 100644 --- a/src/zope/i18n/gettextmessagecatalog.py +++ b/src/zope/i18n/gettextmessagecatalog.py @@ -15,7 +15,7 @@ """ from gettext import GNUTranslations from zope.i18n.interfaces import IGlobalMessageCatalog -from zope.interface import implements +from zope.interface import implementer class _KeyErrorRaisingFallback(object): @@ -23,10 +23,10 @@ class _KeyErrorRaisingFallback(object): raise KeyError(message) +@implementer(IGlobalMessageCatalog) class GettextMessageCatalog(object): """A message catalog based on GNU gettext and Python's gettext module.""" - implements(IGlobalMessageCatalog) def __init__(self, language, domain, path_to_file): """Initialize the message catalog""" diff --git a/src/zope/i18n/locales/__init__.py b/src/zope/i18n/locales/__init__.py index 8c166f6..d6d0d05 100644 --- a/src/zope/i18n/locales/__init__.py +++ b/src/zope/i18n/locales/__init__.py @@ -19,7 +19,7 @@ import os from datetime import datetime, date from time import strptime -from zope.interface import implements +from zope.interface import implementer from zope.i18n.interfaces.locales import ILocale from zope.i18n.interfaces.locales import ILocaleDisplayNames, ILocaleDates from zope.i18n.interfaces.locales import ILocaleVersion, ILocaleIdentity @@ -73,6 +73,7 @@ calendarAliases = {'islamic': ('arabic',), 'islamic-civil': ('civil-arabic',), 'buddhist': ('thai-buddhist', )} +@implementer(ILocaleIdentity) class LocaleIdentity(object): """Represents a unique identification of the locale @@ -100,7 +101,6 @@ class LocaleIdentity(object): >>> id <LocaleIdentity (en, None, US, POSIX)> """ - implements(ILocaleIdentity) def __init__(self, language=None, script=None, territory=None, variant=None): """Initialize object.""" @@ -116,6 +116,7 @@ class LocaleIdentity(object): self.language, self.script, self.territory, self.variant) +@implementer(ILocaleVersion) class LocaleVersion(object): """Represents a particular version of a locale @@ -140,7 +141,6 @@ class LocaleVersion(object): 1 """ - implements(ILocaleVersion) def __init__(self, number, generationDate, notes): """Initialize object.""" @@ -155,6 +155,7 @@ class LocaleVersion(object): (other.generationDate, other.number)) +@implementer(ILocaleDisplayNames) class LocaleDisplayNames(AttributeInheritance): """Locale display names with inheritable data. @@ -178,9 +179,9 @@ class LocaleDisplayNames(AttributeInheritance): >>> locale.displayNames.keys ['fu', 'bahr'] """ - implements(ILocaleDisplayNames) +@implementer(ILocaleTimeZone) class LocaleTimeZone(object): """Specifies one of the timezones of a specific locale. @@ -199,7 +200,6 @@ class LocaleTimeZone(object): >>> tz.cities ['Berlin'] """ - implements(ILocaleTimeZone) def __init__(self, type): """Initialize the object.""" @@ -208,6 +208,7 @@ class LocaleTimeZone(object): self.names = {} +@implementer(ILocaleFormat) class LocaleFormat(object): """Specifies one of the format of a specific format length. @@ -216,7 +217,6 @@ class LocaleFormat(object): itself is often not useful, since other calendar data is required to use the specified pattern for formatting and parsing. """ - implements(ILocaleFormat) def __init__(self, type=None): """Initialize the object.""" @@ -225,11 +225,11 @@ class LocaleFormat(object): self.pattern = u'' +@implementer(ILocaleFormatLength) class LocaleFormatLength(AttributeInheritance): """Specifies one of the format lengths of a specific quantity, like numbers, dates, times and datetimes.""" - implements(ILocaleFormatLength) def __init__(self, type=None): """Initialize the object.""" @@ -237,26 +237,25 @@ class LocaleFormatLength(AttributeInheritance): self.default = None +@implementer(ILocaleMonthContext) class LocaleMonthContext(AttributeInheritance): - implements(ILocaleMonthContext) - def __init__(self, type=None): """Initialize the object.""" self.type = type self.default = u'wide' +@implementer(ILocaleDayContext) class LocaleDayContext(AttributeInheritance): - implements(ILocaleDayContext) - def __init__(self, type=None): """Initialize the object.""" self.type = type self.default = u'wide' +@implementer(ILocaleCalendar) class LocaleCalendar(AttributeInheritance): """Represents locale data for a calendar, like 'gregorian'. @@ -321,7 +320,6 @@ class LocaleCalendar(AttributeInheritance): >>> locale.am u'AM' """ - implements(ILocaleCalendar) def __init__(self, type): """Initialize the object.""" @@ -379,6 +377,7 @@ class LocaleCalendar(AttributeInheritance): return self.days[dayMapping[self.week['firstDay']]][0] +@implementer(ILocaleDates) class LocaleDates(AttributeInheritance): """Simple ILocaleDates implementation that can inherit data from other locales. @@ -476,7 +475,6 @@ class LocaleDates(AttributeInheritance): ValueError: Invalid calendar: irish-catholic """ - implements(ILocaleDates) def getFormatter(self, category, length=None, name=None, calendar=u'gregorian'): @@ -524,10 +522,10 @@ class LocaleDates(AttributeInheritance): return DateTimeFormat(pattern, cal) +@implementer(ILocaleCurrency) class LocaleCurrency(object): """Simple implementation of ILocaleCurrency without inheritance support, since it is not needed for a single currency.""" - implements(ILocaleCurrency) def __init__(self, type): """Initialize object.""" @@ -537,6 +535,7 @@ class LocaleCurrency(object): self.displayName = None +@implementer(ILocaleNumbers) class LocaleNumbers(AttributeInheritance): """Implementation of ILocaleCurrency including inheritance support. @@ -611,7 +610,6 @@ class LocaleNumbers(AttributeInheritance): u'123%' """ - implements(ILocaleNumbers) def getFormatter(self, category, length=None, name=None): """See zope.i18n.interfaces.locales.ILocaleNumbers""" @@ -634,14 +632,14 @@ class LocaleNumbers(AttributeInheritance): return NumberFormat(format.pattern, self.symbols) +@implementer(ILocaleOrientation) class LocaleOrientation(AttributeInheritance): """Implementation of ILocaleOrientation """ - implements(ILocaleOrientation) +@implementer(ILocale) class Locale(AttributeInheritance): """Implementation of the ILocale interface.""" - implements(ILocale) def __init__(self, id): self.id = id diff --git a/src/zope/i18n/locales/inheritance.py b/src/zope/i18n/locales/inheritance.py index 269e71c..3201081 100644 --- a/src/zope/i18n/locales/inheritance.py +++ b/src/zope/i18n/locales/inheritance.py @@ -20,13 +20,14 @@ locale inheritance is not inheritance in the programming sense. """ __docformat__ = 'restructuredtext' -from zope.interface import implements +from zope.interface import implementer from zope.i18n.interfaces.locales import \ ILocaleInheritance, IAttributeInheritance, IDictionaryInheritance class NoParentException(AttributeError): pass +@implementer(ILocaleInheritance) class Inheritance(object): """A simple base version of locale inheritance. @@ -34,7 +35,6 @@ class Inheritance(object): 'ILocaleInheritance' implementations. """ - implements(ILocaleInheritance) # See zope.i18n.interfaces.locales.ILocaleInheritance __parent__ = None @@ -52,6 +52,7 @@ class Inheritance(object): return getattr(parent, self.__name__) +@implementer(IAttributeInheritance) class AttributeInheritance(Inheritance): r"""Implementation of locale inheritance for attributes. @@ -97,7 +98,6 @@ class AttributeInheritance(Inheritance): True """ - implements(IAttributeInheritance) def __setattr__(self, name, value): """See zope.i18n.interfaces.locales.ILocaleInheritance""" @@ -133,6 +133,7 @@ class AttributeInheritance(Inheritance): +@implementer(IDictionaryInheritance) class InheritingDictionary(Inheritance, dict): """Implementation of a dictionary that can also inherit values. @@ -179,7 +180,6 @@ class InheritingDictionary(Inheritance, dict): [(1, 'eins'), (2, 'two'), (3, 'three')] """ - implements(IDictionaryInheritance) def __setitem__(self, name, value): """See zope.i18n.interfaces.locales.ILocaleInheritance""" diff --git a/src/zope/i18n/locales/provider.py b/src/zope/i18n/locales/provider.py index 5bfe339..a39247e 100644 --- a/src/zope/i18n/locales/provider.py +++ b/src/zope/i18n/locales/provider.py @@ -17,17 +17,17 @@ The Locale Provider looks up locales and loads them from the XML data, if necessary. """ import os -from zope.interface import implements +from zope.interface import implementer from zope.i18n.interfaces.locales import ILocaleProvider class LoadLocaleError(Exception): """This error is raised if a locale cannot be loaded.""" +@implementer(ILocaleProvider) class LocaleProvider(object): """A locale provider that get's its data from the XML data.""" - implements(ILocaleProvider) def __init__(self, locale_dir): self._locales = {} diff --git a/src/zope/i18n/negotiator.py b/src/zope/i18n/negotiator.py index 18ace3c..66417c0 100644 --- a/src/zope/i18n/negotiator.py +++ b/src/zope/i18n/negotiator.py @@ -13,7 +13,7 @@ ############################################################################## """Language Negotiator """ -from zope.interface import implements +from zope.interface import implementer from zope.i18n.interfaces import INegotiator from zope.i18n.interfaces import IUserPreferredLanguages @@ -32,8 +32,8 @@ def normalize_langs(langs): n_langs[normalize_lang(l)] = l return n_langs +@implementer(INegotiator) class Negotiator(object): - implements(INegotiator) def getLanguage(self, langs, env): envadapter = IUserPreferredLanguages(env) diff --git a/src/zope/i18n/simpletranslationdomain.py b/src/zope/i18n/simpletranslationdomain.py index 1ed0855..448da5e 100644 --- a/src/zope/i18n/simpletranslationdomain.py +++ b/src/zope/i18n/simpletranslationdomain.py @@ -13,12 +13,13 @@ ############################################################################## """This is a simple implementation of the ITranslationDomain interface. """ -from zope.interface import implements +from zope.interface import implementer from zope.component import getUtility from zope.i18n.interfaces import ITranslationDomain, INegotiator from zope.i18n import interpolate +@implementer(ITranslationDomain) class SimpleTranslationDomain(object): """This is the simplest implementation of the ITranslationDomain I could come up with. @@ -31,7 +32,6 @@ class SimpleTranslationDomain(object): Note: This Translation Domain does not use message catalogs. """ - implements(ITranslationDomain) # See zope.i18n.interfaces.ITranslationDomain domain = None diff --git a/src/zope/i18n/testmessagecatalog.py b/src/zope/i18n/testmessagecatalog.py index 8fd0ac3..f6104e5 100644 --- a/src/zope/i18n/testmessagecatalog.py +++ b/src/zope/i18n/testmessagecatalog.py @@ -14,12 +14,12 @@ """Test message catalog """ -from zope import component, interface +from zope import interface import zope.i18n.interfaces from zope.i18n.translationdomain import TranslationDomain +@interface.implementer(zope.i18n.interfaces.IGlobalMessageCatalog) class TestMessageCatalog: - interface.implements(zope.i18n.interfaces.IGlobalMessageCatalog) language = 'test' diff --git a/src/zope/i18n/tests/test_itranslationdomain.py b/src/zope/i18n/tests/test_itranslationdomain.py index 38f9788..93d457e 100644 --- a/src/zope/i18n/tests/test_itranslationdomain.py +++ b/src/zope/i18n/tests/test_itranslationdomain.py @@ -15,7 +15,7 @@ """ import unittest from zope.interface.verify import verifyObject -from zope.interface import implements +from zope.interface import implementer import zope.component from zope.component.testing import PlacelessSetup @@ -25,9 +25,9 @@ from zope.i18n.interfaces import INegotiator, IUserPreferredLanguages from zope.i18n.interfaces import ITranslationDomain +@implementer(IUserPreferredLanguages) class Environment(object): - implements(IUserPreferredLanguages) def __init__(self, langs=()): self.langs = langs diff --git a/src/zope/i18n/tests/test_negotiator.py b/src/zope/i18n/tests/test_negotiator.py index e87582e..f8a0336 100644 --- a/src/zope/i18n/tests/test_negotiator.py +++ b/src/zope/i18n/tests/test_negotiator.py @@ -18,10 +18,10 @@ import unittest from zope.i18n.negotiator import Negotiator from zope.i18n.interfaces import IUserPreferredLanguages from zope.component.testing import PlacelessSetup -from zope.interface import implements +from zope.interface import implementer +@implementer(IUserPreferredLanguages) class Env(object): - implements(IUserPreferredLanguages) def __init__(self, langs=()): self.langs = langs diff --git a/src/zope/i18n/tests/testi18nawareobject.py b/src/zope/i18n/tests/testi18nawareobject.py index 11759ce..8d52e43 100644 --- a/src/zope/i18n/tests/testi18nawareobject.py +++ b/src/zope/i18n/tests/testi18nawareobject.py @@ -17,13 +17,12 @@ import unittest from zope.i18n.interfaces import II18nAware from zope.i18n.tests.testii18naware import TestII18nAware -from zope.interface import implements +from zope.interface import implementer +@implementer(II18nAware) class I18nAwareContentObject(object): - implements(II18nAware) - def __init__(self): self.content = {} self.defaultLanguage = 'en' |