diff options
Diffstat (limited to 'src/zope/i18n/locales/__init__.py')
-rw-r--r-- | src/zope/i18n/locales/__init__.py | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/zope/i18n/locales/__init__.py b/src/zope/i18n/locales/__init__.py index 030c453..12009a6 100644 --- a/src/zope/i18n/locales/__init__.py +++ b/src/zope/i18n/locales/__init__.py @@ -29,8 +29,10 @@ from zope.i18n.interfaces.locales import ILocaleOrientation from zope.i18n.interfaces.locales import ILocaleDayContext, ILocaleMonthContext from zope.i18n.format import NumberFormat, DateTimeFormat from zope.i18n.locales.inheritance import \ - AttributeInheritance, InheritingDictionary, NoParentException -from zope.i18n.locales.provider import LocaleProvider, LoadLocaleError + AttributeInheritance, InheritingDictionary, NoParentException +# LoadLocaleError is not used, but might be imported from here by others. +from zope.i18n.locales.provider import LoadLocaleError # noqa +from zope.i18n.locales.provider import LocaleProvider # Setup the locale directory @@ -73,6 +75,7 @@ calendarAliases = {'islamic': ('arabic',), 'islamic-civil': ('civil-arabic',), 'buddhist': ('thai-buddhist', )} + @implementer(ILocaleIdentity) class LocaleIdentity(object): """Represents a unique identification of the locale @@ -102,7 +105,8 @@ class LocaleIdentity(object): <LocaleIdentity (en, None, US, POSIX)> """ - def __init__(self, language=None, script=None, territory=None, variant=None): + def __init__(self, language=None, script=None, + territory=None, variant=None): """Initialize object.""" self.language = language self.script = script @@ -112,7 +116,7 @@ class LocaleIdentity(object): def __repr__(self): """See zope.i18n.interfaces.ILocaleIdentity """ - return "<LocaleIdentity (%s, %s, %s, %s)>" %( + return "<LocaleIdentity (%s, %s, %s, %s)>" % ( self.language, self.script, self.territory, self.variant) @@ -158,6 +162,7 @@ class LocaleVersion(object): return ((self.generationDate, self.number) == (other.generationDate, other.number)) + @implementer(ILocaleDisplayNames) class LocaleDisplayNames(AttributeInheritance): """Locale display names with inheritable data. @@ -233,7 +238,6 @@ class LocaleFormatLength(AttributeInheritance): """Specifies one of the format lengths of a specific quantity, like numbers, dates, times and datetimes.""" - def __init__(self, type=None): """Initialize the object.""" self.type = type @@ -343,7 +347,8 @@ class LocaleCalendar(AttributeInheritance): def getMonthNames(self): """See zope.i18n.interfaces.ILocaleCalendar""" - return [self.months.get(type, (None, None))[0] for type in range(1, 13)] + return [self.months.get(type, (None, None))[0] + for type in range(1, 13)] def getMonthTypeFromName(self, name): """See zope.i18n.interfaces.ILocaleCalendar""" @@ -353,7 +358,8 @@ class LocaleCalendar(AttributeInheritance): def getMonthAbbreviations(self): """See zope.i18n.interfaces.ILocaleCalendar""" - return [self.months.get(type, (None, None))[1] for type in range(1, 13)] + return [self.months.get(type, (None, None))[1] + for type in range(1, 13)] def getMonthTypeFromAbbreviation(self, abbr): """See zope.i18n.interfaces.ILocaleCalendar""" @@ -505,11 +511,11 @@ class LocaleDates(AttributeInheritance): cal = self.calendars[calendar] - formats = getattr(cal, category+'Formats') + formats = getattr(cal, category + 'Formats') if length is None: length = getattr( cal, - 'default'+category[0].upper()+category[1:]+'Format', + 'default' + category[0].upper() + category[1:] + 'Format', list(formats.keys())[0]) # 'datetime' is always a bit special; we often do not have a length @@ -652,6 +658,7 @@ class LocaleOrientation(AttributeInheritance): """Implementation of ILocaleOrientation """ + @implementer(ILocale) class Locale(AttributeInheritance): """Implementation of the ILocale interface.""" @@ -690,7 +697,7 @@ class Locale(AttributeInheritance): # Notice that 'pieces' is always empty. pieces = [key + '=' + type for (key, type) in ()] assert not pieces - if pieces: # pragma: no cover + if pieces: # pragma: no cover id_string += '@' + ','.join(pieces) return id_string |