Module Expr Str Import alias Import alias Import alias Import alias ImportFrom alias Import alias ImportFrom alias Import alias Assign NameStore Dict Assign NameStore NameLoad ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad If CompareIs NameLoad NameLoad body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr BinOpAdd Call AttributeLoad NameLoad attr Str Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str If CompareIs NameLoad NameLoad body Assign NameStore AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body Return Call AttributeLoad NameLoad attr NameLoad keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword AttributeLoad NameLoad attr keyword NameLoad If AttributeLoad NameLoad attr body Return AttributeLoad NameLoad attr Return AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Return Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd AttributeLoad NameLoad attr Str NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr Str decorator_list NameLoad FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr Str decorator_list NameLoad FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr Str decorator_list NameLoad FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr Str decorator_list NameLoad decorator_list Assign NameStore Call NameLoad Str Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr FunctionDef arguments args defaults body Expr Str Global identifier identifier identifier identifier identifier identifier Assign NameStore Call NameLoad Str keyword NameLoad Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assign NameStore NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str If NameLoad body ImportFrom alias Assign NameStore Call NameLoad NameLoad keyword NameLoad Assign SubscriptStore AttributeLoad AttributeLoad NameLoad attr attr Index Str AttributeLoad NameLoad attr orelse Assign NameStore BinOpMod Str Call AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr NameLoad keyword Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad orelse Expr Call AttributeLoad NameLoad attr NameLoad keyword Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad keyword NameLoad decorator_list ClassDef bases AttributeLoad NameLoad attr body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad Str vararg body Expr Str If UnaryOpNot NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad If CompareIs AttributeLoad NameLoad attr NameLoad body Return NameLoad Assign NameStore Call NameLoad AttributeLoad NameLoad attr NameLoad Assign NameStore BinOpMod NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body If UnaryOpNot NameLoad body Assign NameStore Call AttributeLoad NameLoad attr If UnaryOpNot SubscriptLoad NameLoad Index Num body Assign NameStore Str orelse Assign NameStore SubscriptLoad NameLoad Index Num Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr BinOpAdd Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword NameLoad keyword ListLoad NameLoad keyword NameLoad If AttributeLoad NameLoad attr body Assign NameStore AttributeLoad NameLoad attr orelse Assign NameStore AttributeLoad NameLoad attr Assign NameStore Call NameLoad NameLoad Return NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad Assign NameStore Call NameLoad AttributeLoad NameLoad attr keyword NameLoad keyword NameLoad keyword AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str If CompareIs NameLoad NameLoad body Assign NameStore TupleLoad NameLoad orelse If Call NameLoad NameLoad NameLoad body Assign NameStore Dict If Call NameLoad AttributeLoad NameLoad attr NameLoad body For TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr body Assign SubscriptStore NameLoad Index NameLoad Call AttributeLoad NameLoad attr NameLoad For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr body Assign SubscriptStore NameLoad Index NameLoad Call AttributeLoad NameLoad attr NameLoad orelse Assign NameStore Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body TryExcept body Return Call AttributeLoad NameLoad attr NameLoad handlers ExceptHandler type NameLoad body Return Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call NameLoad Str Raise Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Return Call AttributeLoad NameLoad attr NameLoad decorator_list If AttributeLoad NameLoad attr body FunctionDef arguments args NameParam defaults body Assign NameStore Call NameLoad Str Raise Call NameLoad NameLoad decorator_list decorator_list FunctionDef arguments args NameParam defaults body Expr Str If CompareIn NameLoad NameLoad body Return Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index NameLoad Assign NameStore BinOpMod Str Call AttributeLoad NameLoad attr Assign NameStore Lambda arguments args NameParam defaults Call AttributeLoad NameLoad attr NameLoad keyword Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad keyword ListLoad NameLoad Assign NameStore ListLoad Str Assign NameStore BoolOpOr Call NameLoad NameLoad Str NameLoad Call NameLoad NameLoad Str Assign NameStore Call NameLoad For NameStore NameLoad body If CompareIsNot Call NameLoad NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Dict Str Str Str Str Str Str Str Str For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad body If BoolOpAnd CompareIn NameLoad NameLoad CompareNotIn NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Assign SubscriptStore NameLoad Index NameLoad NameLoad Return Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str Assign NameStore NameLoad If UnaryOpNot Call NameLoad NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad If Call NameLoad NameLoad NameLoad body Return Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str If Call NameLoad NameLoad NameLoad body Return Call NameLoad GeneratorExp Call NameLoad NameLoad NameLoad comprehension NameStore NameLoad If Call NameLoad NameLoad NameLoad body Assign NameStore Dict For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad body Assign NameStore Call NameLoad NameLoad NameLoad Assign SubscriptStore NameLoad Index NameLoad NameLoad Return NameLoad Return Call NameLoad NameLoad NameLoad decorator_list ClassDef bases AttributeLoad NameLoad attr body Expr Str FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad keyword Num keyword NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr TryFinally body Expr Call AttributeLoad NameLoad attr NameLoad finalbody Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign AttributeStore NameLoad attr Call NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr Call NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad decorator_list decorator_list
N/A N/A 
gettext for openstack-common modules.

Usual usage in an openstack.common module:

    from bareon.openstack.common.gettextutils import _
 N/A copy N/A functools N/A gettext N/A locale logging handlers N/A os babel localedata N/A six N/A _AVAILABLE_LANGUAGES N/A N/A USE_LAZY False TranslatorFactory N/A object N/A N/A Create translator functions
     __init__ N/A N/A self domain lazy localedir N/A False None N/A N/A Establish a set of translation functions for the domain.

        :param domain: Name of translation domain,
                       specifying a message catalog.
        :type domain: str
        :param lazy: Delays translation until a message is emitted.
                     Defaults to False.
        :type lazy: Boolean
        :param localedir: Directory with translation catalogs.
        :type localedir: str
         N/A N/A self domain domain N/A N/A self lazy lazy N/A N/A localedir None N/A N/A localedir N/A N/A N/A os environ get N/A N/A N/A domain upper _LOCALEDIR N/A N/A self localedir localedir N/A _make_translation_func N/A N/A self domain N/A None N/A N/A Return a new translation function ready for use.

        Takes into account whether or not lazy translation is being
        done.

        The domain can be specified to override the default from the
        factory, but the localedir from the factory is always used
        because we assume the log-level translation catalogs are
        installed in the same directory as the main application
        catalog.

         N/A N/A domain None N/A N/A domain N/A self domain N/A N/A self lazy N/A N/A N/A N/A functools partial Message domain domain N/A t N/A N/A gettext translation domain localedir N/A self localedir fallback True N/A N/A six PY3 N/A N/A N/A t gettext N/A N/A t ugettext N/A primary N/A N/A self N/A N/A N/A The default translation function. N/A N/A N/A self _make_translation_func N/A property _make_log_translation_func N/A N/A self level N/A N/A N/A N/A N/A self _make_translation_func N/A N/A N/A self domain -log- level N/A log_info N/A N/A self N/A N/A N/A Translate info-level log messages. N/A N/A N/A self _make_log_translation_func info N/A property log_warning N/A N/A self N/A N/A N/A Translate warning-level log messages. N/A N/A N/A self _make_log_translation_func warning N/A property log_error N/A N/A self N/A N/A N/A Translate error-level log messages. N/A N/A N/A self _make_log_translation_func error N/A property log_critical N/A N/A self N/A N/A N/A Translate critical-level log messages. N/A N/A N/A self _make_log_translation_func critical N/A property N/A N/A _translators N/A TranslatorFactory bareon N/A _ N/A _translators primary N/A _LI N/A _translators log_info N/A _LW N/A _translators log_warning N/A _LE N/A _translators log_error N/A _LC N/A _translators log_critical enable_lazy N/A N/A N/A N/A N/A Convenience function for configuring _() to use lazy gettext

    Call this at the start of execution to enable the gettextutils._
    function to use lazy gettext functionality. This is useful if
    your project is importing _ directly instead of using the
    gettextutils.install() way of importing the _ function.
     N/A _ _LI _LW _LE _LC USE_LAZY N/A tf N/A TranslatorFactory bareon lazy True N/A _ N/A tf primary N/A _LI N/A tf log_info N/A _LW N/A tf log_warning N/A _LE N/A tf log_error N/A _LC N/A tf log_critical N/A USE_LAZY True N/A install N/A N/A domain lazy N/A False N/A N/A Install a _() function using the given translation domain.

    Given a translation domain, install a _() function using gettext's
    install() function.

    The main difference from gettext.install() is that we allow
    overriding the default localedir (e.g. /usr/share/locale) using
    a translation-domain-specific environment variable (e.g.
    NOVA_LOCALEDIR).

    :param domain: the translation domain
    :param lazy: indicates whether or not to install the lazy _() function.
                 The lazy _() introduces a way to do deferred translation
                 of messages by installing a _ that builds Message objects,
                 instead of strings, which can then be lazily translated into
                 any available locale.
     N/A lazy N/A six moves N/A tf N/A TranslatorFactory domain lazy True N/A N/A N/A N/A moves builtins __dict__ N/A _ N/A tf primary N/A N/A localedir N/A %s_LOCALEDIR N/A N/A domain upper N/A N/A six PY3 N/A N/A N/A N/A gettext install domain localedir N/A N/A N/A os environ get localedir N/A N/A N/A N/A gettext install domain localedir N/A N/A N/A os environ get localedir unicode True N/A Message N/A N/A six text_type N/A N/A A Message object is a unicode object that can be translated.

    Translation of Message is done explicitly using the translate() method.
    For all non-translation intents and purposes, a Message is simply unicode,
    and can be treated as such.
     __new__ N/A N/A cls msgid msgtext params domain N/A None None bareon args N/A N/A Create a new Message object.

        In order for translation to work gettext requires a message ID, this
        msgid will be used as the base unicode text. It is also possible
        for the msgid and the base unicode text to be different by passing
        the msgtext parameter.
         N/A N/A msgtext N/A N/A msgtext N/A N/A Message _translate_msgid msgid domain N/A msg N/A N/A N/A super Message cls __new__ cls msgtext N/A N/A msg msgid msgid N/A N/A msg domain domain N/A N/A msg params params N/A msg N/A translate N/A N/A self desired_locale N/A None N/A N/A Translate this message to the desired locale.

        :param desired_locale: The desired locale to translate the message to,
                               if no locale is provided the message will be
                               translated to the system's default locale.

        :returns: the translated message in unicode
         N/A translated_message N/A N/A Message _translate_msgid N/A self msgid N/A self domain desired_locale N/A N/A N/A self params None N/A N/A translated_message N/A translated_params N/A _translate_args N/A self params desired_locale N/A translated_message N/A translated_message translated_params N/A translated_message N/A _translate_msgid N/A N/A msgid domain desired_locale N/A None N/A N/A N/A desired_locale N/A N/A system_locale N/A N/A locale getdefaultlocale N/A N/A N/A system_locale N/A 0 N/A N/A desired_locale en_US N/A N/A desired_locale N/A system_locale N/A 0 N/A locale_dir N/A N/A N/A os environ get N/A N/A N/A domain upper _LOCALEDIR N/A lang N/A N/A gettext translation domain localedir locale_dir languages N/A desired_locale fallback True N/A N/A six PY3 N/A N/A translator N/A lang gettext N/A N/A translator N/A lang ugettext N/A translated_message N/A translator msgid N/A translated_message N/A staticmethod __mod__ N/A N/A self other N/A N/A N/A params N/A N/A self _sanitize_mod_params other N/A unicode_mod N/A N/A N/A super Message self __mod__ params N/A modded N/A Message N/A self msgid msgtext unicode_mod params params domain N/A self domain N/A modded N/A _sanitize_mod_params N/A N/A self other N/A N/A N/A Sanitize the object being modded with this Message.

        - Add support for modding 'None' so translation supports it
        - Trim the modded object, which can be a large dictionary, to only
        those keys that would actually be used in a translation
        - Snapshot the object being modded, in case the message is
        translated, it will be used as it was when the Message was created
         N/A N/A other None N/A N/A params N/A other N/A N/A N/A isinstance other dict N/A N/A params N/A N/A N/A isinstance N/A self params dict N/A N/A N/A key val N/A N/A N/A self params items N/A N/A N/A params N/A key N/A N/A self _copy_param val N/A N/A key val N/A N/A other items N/A N/A N/A params N/A key N/A N/A self _copy_param val N/A N/A params N/A N/A self _copy_param other N/A params N/A _copy_param N/A N/A self param N/A N/A N/A N/A N/A N/A N/A copy deepcopy param N/A N/A N/A Exception N/A N/A N/A N/A six text_type param N/A __add__ N/A N/A self other N/A N/A N/A msg N/A _ Message objects do not support addition. N/A N/A TypeError msg N/A __radd__ N/A N/A self other N/A N/A N/A N/A N/A self __add__ other N/A N/A N/A six PY2 N/A __str__ N/A N/A self N/A N/A N/A msg N/A _ Message objects do not support str() because they may contain non-ascii characters. Please use unicode() or translate() instead. N/A N/A UnicodeError msg N/A N/A get_available_languages N/A N/A domain N/A N/A N/A Lists the available languages for the given translation domain.

    :param domain: the domain to get languages for
     N/A N/A domain _AVAILABLE_LANGUAGES N/A N/A N/A N/A copy copy N/A _AVAILABLE_LANGUAGES N/A domain N/A localedir N/A %s_LOCALEDIR N/A N/A domain upper N/A find N/A N/A N/A x N/A N/A N/A gettext find domain localedir N/A N/A N/A os environ get localedir languages N/A x N/A language_list N/A en_US N/A list_identifiers N/A N/A getattr localedata list None N/A getattr localedata locale_identifiers N/A locale_identifiers N/A list_identifiers N/A i locale_identifiers N/A N/A N/A N/A find i None N/A N/A N/A N/A language_list append i N/A aliases N/A zh zh_Hant_HK zh_Hant fil zh_CN zh_HK zh_TW tl_PH N/A N/A locale alias N/A N/A six iteritems aliases N/A N/A N/A N/A locale language_list N/A alias language_list N/A N/A N/A N/A language_list append alias N/A N/A _AVAILABLE_LANGUAGES N/A domain language_list N/A N/A N/A copy copy language_list N/A translate N/A N/A obj desired_locale N/A None N/A N/A Gets the translated unicode representation of the given object.

    If the object is not translatable it is returned as-is.
    If the locale is None the object is translated to the system locale.

    :param obj: the object to translate
    :param desired_locale: the locale to translate the message to, if None the
                           default system locale will be used
    :returns: the translated object in unicode, or the original object if
              it could not be translated
     N/A message obj N/A N/A N/A isinstance message Message N/A N/A message N/A N/A six text_type obj N/A N/A isinstance message Message N/A N/A N/A N/A message translate desired_locale N/A obj N/A _translate_args N/A N/A args desired_locale N/A None N/A N/A Translates all the translatable elements of the given arguments object.

    This method is used for translating the translatable values in method
    arguments which include values of tuples or dictionaries.
    If the object is not a tuple or a dictionary the object itself is
    translated if it is translatable.

    If the locale is None the object is translated to the system locale.

    :param args: the args to translate
    :param desired_locale: the locale to translate the args to, if None the
                           default system locale will be used
    :returns: a new args object with the translated contents of the original
     N/A N/A isinstance args tuple N/A N/A N/A tuple N/A N/A translate v desired_locale N/A v args N/A N/A isinstance args dict N/A N/A translated_dict N/A N/A N/A k v N/A N/A six iteritems args N/A N/A translated_v N/A translate v desired_locale N/A N/A translated_dict N/A k translated_v N/A translated_dict N/A N/A translate args desired_locale N/A TranslationHandler N/A N/A handlers MemoryHandler N/A N/A Handler that translates records before logging them.

    The TranslationHandler takes a locale and a target logging.Handler object
    to forward LogRecord objects to after translating them. This handler
    depends on Message objects being logged, instead of regular strings.

    The handler can be configured declaratively in the logging.conf as follows:

        [handlers]
        keys = translatedlog, translator

        [handler_translatedlog]
        class = handlers.WatchedFileHandler
        args = ('/var/log/api-localized.log',)
        formatter = context

        [handler_translator]
        class = openstack.common.log.TranslationHandler
        target = translatedlog
        args = ('zh_CN',)

    If the specified locale is not available in the system, the handler will
    log in the default locale.
     __init__ N/A N/A self locale target N/A None None N/A N/A Initialize a TranslationHandler

        :param locale: locale to use for translating messages
        :param target: logging.Handler object to forward
                       LogRecord objects to after translation
         N/A N/A N/A N/A handlers MemoryHandler __init__ self capacity 0 target target N/A N/A self locale locale N/A setFormatter N/A N/A self fmt N/A N/A N/A N/A N/A N/A self target setFormatter fmt N/A emit N/A N/A self record N/A N/A N/A original_msg N/A record msg N/A original_args N/A record args N/A N/A N/A N/A N/A self _translate_and_log_record record N/A N/A N/A record msg original_msg N/A N/A record args original_args N/A _translate_and_log_record N/A N/A self record N/A N/A N/A N/A record msg N/A translate N/A record msg N/A self locale N/A N/A record args N/A _translate_args N/A record args N/A self locale N/A N/A N/A N/A self target emit record N/A N/A