/usr/lib/python2.6/site-packages/cinderclient/openstack/common
NameSizeModeActions
apiclient/-0755rm
gettextutils.py180410644editdlrm
gettextutils.pyc167620644editdlrm
importutils.py21890644editdlrm
importutils.pyc23650644editdlrm
strutils.py102290644editdlrm
strutils.pyc95520644editdlrm
__init__.py6440644editdlrm
__init__.pyc2750644editdlrm
Edit: /usr/lib/python2.6/site-packages/cinderclient/openstack/common/gettextutils.pyc (16762B)
Ñò =vVc @s&dZddkZddkZddkZddklZddkZddklZddk Z hZ e a de fd„ƒYZedƒZeiZeiZeiZeiZeiZd„Zd „Zd e ifd „ƒYZd „Zdd „Z dd„Z!dei"fd„ƒYZ#dS(s„ gettext for openstack-common modules. Usual usage in an openstack.common module: from openstack.common.gettextutils import _ iÿÿÿÿN(thandlers(t localedatatTranslatorFactorycBszeZdZd d„Zd d„Zed„ƒZd„Zed„ƒZ ed„ƒZ ed„ƒZ ed„ƒZ RS( s Create translator functions cCsC||_|djo tii|iƒdƒ}n||_dS(s¨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 t _LOCALEDIRN(tdomaintNonetostenvirontgettuppert localedir(tselfRR ((sW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pyt__init__,s   cskˆdjo |i‰ntiˆd|idtƒ}tio |in|i‰‡‡fd†}|S(s¨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. R tfallbackcs"tot|dˆƒSˆ|ƒS(s,oslo.i18n.gettextutils translation function.R(tUSE_LAZYtMessage(tmsg(tmR(sW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pytfSsN( RRtgettextt translationR tTruetsixtPY3tugettext(R RttR((RRsW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pyt_make_translation_func=s     cCs |iƒS(s!The default translation function.(R(R ((sW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pytprimaryZscCs|i|id|ƒS(Ns-log-(RR(R tlevel((sW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pyt_make_log_translation_func_scCs |idƒS(s"Translate info-level log messages.tinfo(R(R ((sW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pytlog_infobscCs |idƒS(s%Translate warning-level log messages.twarning(R(R ((sW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pyt log_warninggscCs |idƒS(s#Translate error-level log messages.terror(R(R ((sW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pyt log_errorlscCs |idƒS(s&Translate critical-level log messages.tcritical(R(R ((sW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pyt log_criticalqsN( t__name__t __module__t__doc__RR RtpropertyRRRR!R#R%(((sW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pyR(s   t cinderclientcCs tadS(sCConvenience 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(RR(((sW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pyt enable_lazys cCs3ddkl}t|ƒ}|i|iidt staticmethodR2RHRGRORXRYRtPY2R[(((sW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pyR°s       c s.ˆtjotitˆƒSdˆiƒ‰‡‡fd†}dg}ttddƒp ttdƒ}|ƒ}x2|D]*}||ƒdj o|i|ƒq|q|Whdd6dd 6d d 6d d 6}xHti|ƒD]7\}}||jo||jo|i|ƒqÜqÜW|tˆFs R?tlisttlocale_identifierstzh_CNtzhtzh_HKt zh_Hant_HKtzh_TWtzh_Hantttl_PHtfilN( t_AVAILABLE_LANGUAGESRRR tgetattrRRtappendRt iteritems( RR^t language_listtlist_identifiersRbtitaliasestlocale_talias((RR sW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pytget_available_languages=s,       cCsK|}t|tƒpti|ƒ}nt|tƒo|i|ƒS|S(só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 (RLRRRUR>(tobjR;tmessage((sW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pyR>ms csŒt|tƒot‡fd†|DƒƒSt|tƒoDh}x6ti|ƒD]%\}}t|ˆƒ}|||(t.0tv(R;(sW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pys •s (RLttupleRMRRnR>(R9R;ttranslated_dicttkRyt translated_v((R;sW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pyR:…s tTranslationHandlercBs8eZdZddd„Zd„Zd„Zd„ZRS(s<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. cCs)tii|ddd|ƒ||_dS(sÞInitialize a TranslationHandler :param locale: locale to use for translating messages :param target: logging.Handler object to forward LogRecord objects to after translation tcapacityittargetN(Rt MemoryHandlerR RA(R RAR€((sW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pyR ¹s cCs|ii|ƒdS(N(R€t setFormatter(R tfmt((sW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pyR‚ÈscCs=|i}|i}z|i|ƒWd||_||_XdS(N(RR9t_translate_and_log_record(R trecordt original_msgt original_args((sW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pytemitËs    cCsDt|i|iƒ|_t|i|iƒ|_|ii|ƒdS(N(R>RRAR:R9R€Rˆ(R R…((sW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pyR„×sN(R&R'R(RR R‚RˆR„(((sW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pyR~Ÿs   ($R(RRRRAtloggingRRtbabelRRRktFalseRtobjectRt _translatorsRR-Rt_LIR!t_LWR#t_LER%t_LCR+R1RURRuRR>R:RR~(((sW/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/gettextutils.pyts.     T        0