From: Felix Schwarz Date: Fri, 10 Aug 2012 20:41:22 +0000 (+0000) Subject: don't use class-level variable as default value for method parameters in babel.suppor... X-Git-Tag: 1.0~152 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=079fd101424171c9bc9e5f0a30fd739f4d5f8674;p=thirdparty%2Fbabel.git don't use class-level variable as default value for method parameters in babel.support.Translations to ease custom inheritance (see #276, initial patch by Christopher A. Stelma) --- diff --git a/babel/support.py b/babel/support.py index dbccb26a..3a8d5c05 100644 --- a/babel/support.py +++ b/babel/support.py @@ -287,26 +287,29 @@ class Translations(gettext.GNUTranslations, object): DEFAULT_DOMAIN = 'messages' - def __init__(self, fileobj=None, domain=DEFAULT_DOMAIN): + def __init__(self, fileobj=None, domain=None): """Initialize the translations catalog. :param fileobj: the file-like object the translation should be read from + :param domain: the message domain (default: 'messages') """ + if domain is None: + domain = self.DEFAULT_DOMAIN gettext.GNUTranslations.__init__(self, fp=fileobj) self.files = filter(None, [getattr(fileobj, 'name', None)]) self.domain = domain self._domains = {} @classmethod - def load(cls, dirname=None, locales=None, domain=DEFAULT_DOMAIN): + def load(cls, dirname=None, locales=None, domain=None): """Load translations from the given directory. :param dirname: the directory containing the ``MO`` files :param locales: the list of locales in order of preference (items in this list can be either `Locale` objects or locale strings) - :param domain: the message domain + :param domain: the message domain (default: 'messages') :return: the loaded catalog, or a ``NullTranslations`` instance if no matching translations were found :rtype: `Translations`