/opt/alt/python37/lib/python3.7/site-packages/babel/__pycache__
NameSizeModeActions
core.cpython-37.opt-1.pyc352160644editdlrm
core.cpython-37.pyc352160644editdlrm
dates.cpython-37.opt-1.pyc554440644editdlrm
dates.cpython-37.pyc554870644editdlrm
languages.cpython-37.opt-1.pyc31080644editdlrm
languages.cpython-37.pyc31080644editdlrm
lists.cpython-37.opt-1.pyc26780644editdlrm
lists.cpython-37.pyc26780644editdlrm
localedata.cpython-37.opt-1.pyc78870644editdlrm
localedata.cpython-37.pyc78870644editdlrm
numbers.cpython-37.opt-1.pyc320140644editdlrm
numbers.cpython-37.pyc321300644editdlrm
plural.cpython-37.opt-1.pyc219900644editdlrm
plural.cpython-37.pyc219900644editdlrm
support.cpython-37.opt-1.pyc228320644editdlrm
support.cpython-37.pyc228320644editdlrm
units.cpython-37.opt-1.pyc85080644editdlrm
units.cpython-37.pyc85080644editdlrm
util.cpython-37.opt-1.pyc70040644editdlrm
util.cpython-37.pyc70040644editdlrm
_compat.cpython-37.opt-1.pyc21410644editdlrm
_compat.cpython-37.pyc21410644editdlrm
__init__.cpython-37.opt-1.pyc9040644editdlrm
__init__.cpython-37.pyc9040644editdlrm
Edit: /opt/alt/python37/lib/python3.7/site-packages/babel/__pycache__/support.cpython-37.pyc (22832B)
B `^X@sdZddlZddlZddlmZddlmZmZmZm Z ddl m Z m Z m Z mZmZddlmZmZmZGdddeZGd d d eZGd d d ejeZGd ddeejZdS)a- babel.support ~~~~~~~~~~~~~ Several classes and functions that help with integrating and using Babel in applications. .. note: the code in this module is not used by Babel itself :copyright: (c) 2013-2021 by the Babel Team. :license: BSD, see LICENSE for more details. N)Locale) format_dateformat_datetime format_timeformat_timedelta) format_numberformat_decimalformat_currencyformat_percentformat_scientific)PY2 text_typetext_to_nativec@sneZdZdZdddZdddZddd Zdd d Zd ddZddZ d!ddZ ddZ d"ddZ ddZ dS)#FormataCWrapper class providing the various date and number formatting functions bound to a specific locale and time-zone. >>> from babel.util import UTC >>> from datetime import date >>> fmt = Format('en_US', UTC) >>> fmt.date(date(2007, 4, 1)) u'Apr 1, 2007' >>> fmt.decimal(1.2345) u'1.234' NcCst||_||_dS)zInitialize the formatter. :param locale: the locale identifier or `Locale` instance :param tzinfo: the time-zone info (a `tzinfo` instance or `None`) N)rparselocaletzinfo)selfrrr>/opt/alt/python37/lib/python3.7/site-packages/babel/support.py__init__'s zFormat.__init__mediumcCst|||jdS)zReturn a date formatted according to the given pattern. >>> from datetime import date >>> fmt = Format('en_US') >>> fmt.date(date(2007, 4, 1)) u'Apr 1, 2007' )r)rr)rdateformatrrrr0sz Format.datecCst|||j|jdS)a6Return a date and time formatted according to the given pattern. >>> from datetime import datetime >>> from pytz import timezone >>> fmt = Format('en_US', tzinfo=timezone('US/Eastern')) >>> fmt.datetime(datetime(2007, 4, 1, 15, 30)) u'Apr 1, 2007, 11:30:00 AM' )rr)rrr)rdatetimerrrrr:s zFormat.datetimecCst|||j|jdS)aReturn a time formatted according to the given pattern. >>> from datetime import datetime >>> from pytz import timezone >>> fmt = Format('en_US', tzinfo=timezone('US/Eastern')) >>> fmt.time(datetime(2007, 4, 1, 15, 30)) u'11:30:00 AM' )rr)rrr)rtimerrrrrFs z Format.timesecond333333?longFcCst||||||jdS)zReturn a time delta according to the rules of the given locale. >>> from datetime import timedelta >>> fmt = Format('en_US') >>> fmt.timedelta(timedelta(weeks=11)) u'3 months' ) granularity thresholdr add_directionr)rr)rZdeltarr rr!rrr timedeltaQs zFormat.timedeltacCst||jdS)zReturn an integer number formatted for the locale. >>> fmt = Format('en_US') >>> fmt.number(1099) u'1,099' )r)rr)rnumberrrrr#_sz Format.numbercCst|||jdS)zReturn a decimal number formatted for the locale. >>> fmt = Format('en_US') >>> fmt.decimal(1.2345) u'1.234' )r)rr)rr#rrrrdecimalhszFormat.decimalcCst|||jdS)zHReturn a number in the given currency formatted for the locale. )r)r r)rr#currencyrrrr%qszFormat.currencycCst|||jdS)zReturn a number formatted as percentage for the locale. >>> fmt = Format('en_US') >>> fmt.percent(0.34) u'34%' )r)r r)rr#rrrrpercentvszFormat.percentcCst||jdS)zLReturn a number formatted using scientific notation for the locale. )r)r r)rr#rrr scientificszFormat.scientific)N)Nr)Nr)Nr)rrrF)N)N)__name__ __module__ __qualname____doc__rrrrr"r#r$r%r&r'rrrrrs     rc@seZdZdZddddddgZdd Zed d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Zdd?Z!d@dAZ"dBdCZ#dDS)E LazyProxyaClass for proxy objects that delegate to a specified function to evaluate the actual object. >>> def greeting(name='world'): ... return 'Hello, %s!' % name >>> lazy_greeting = LazyProxy(greeting, name='Joe') >>> print(lazy_greeting) Hello, Joe! >>> u' ' + lazy_greeting u' Hello, Joe!' >>> u'(%s)' % lazy_greeting u'(Hello, Joe!)' This can be used, for example, to implement lazy translation functions that delay the actual translation until the string is actually used. The rationale for such behavior is that the locale of the user may not always be available. In web applications, you only know the locale when processing a request. The proxy implementation attempts to be as complete as possible, so that the lazy objects should mostly work as expected, for example for sorting: >>> greetings = [ ... LazyProxy(greeting, 'world'), ... LazyProxy(greeting, 'Joe'), ... LazyProxy(greeting, 'universe'), ... ] >>> greetings.sort() >>> for greeting in greetings: ... print(greeting) Hello, Joe! Hello, universe! Hello, world! _func_args_kwargs_value_is_cache_enabled_attribute_errorcOsd|dd}t|d|t|d|t|d|t|d|t|ddt|dddS) N enable_cacheTr-r.r/r1r0r2)popobject __setattr__)rfuncargskwargsZis_cache_enabledrrrrs zLazyProxy.__init__c Csp|jdkrjy|j|j|j}Wn2tk rP}zt|d|Wdd}~XYnX|js\|St|d||jS)Nr2r0)r0r-r.r/AttributeErrorr5r6r1)rvalueerrorrrrr;s zLazyProxy.valuecCs ||jkS)N)r;)rkeyrrr __contains__szLazyProxy.__contains__cCs t|jS)N)boolr;)rrrr __nonzero__szLazyProxy.__nonzero__cCs t|jS)N)dirr;)rrrr__dir__szLazyProxy.__dir__cCs t|jS)N)iterr;)rrrr__iter__szLazyProxy.__iter__cCs t|jS)N)lenr;)rrrr__len__szLazyProxy.__len__cCs t|jS)N)strr;)rrrr__str__szLazyProxy.__str__cCs t|jS)N)Zunicoder;)rrrr __unicode__szLazyProxy.__unicode__cCs |j|S)N)r;)rotherrrr__add__szLazyProxy.__add__cCs ||jS)N)r;)rrJrrr__radd__szLazyProxy.__radd__cCs |j|S)N)r;)rrJrrr__mod__szLazyProxy.__mod__cCs ||jS)N)r;)rrJrrr__rmod__szLazyProxy.__rmod__cCs |j|S)N)r;)rrJrrr__mul__szLazyProxy.__mul__cCs ||jS)N)r;)rrJrrr__rmul__szLazyProxy.__rmul__cOs |j||S)N)r;)rr8r9rrr__call__szLazyProxy.__call__cCs |j|kS)N)r;)rrJrrr__lt__szLazyProxy.__lt__cCs |j|kS)N)r;)rrJrrr__le__szLazyProxy.__le__cCs |j|kS)N)r;)rrJrrr__eq__szLazyProxy.__eq__cCs |j|kS)N)r;)rrJrrr__ne__szLazyProxy.__ne__cCs |j|kS)N)r;)rrJrrr__gt__szLazyProxy.__gt__cCs |j|kS)N)r;)rrJrrr__ge__szLazyProxy.__ge__cCst|j|dS)N)delattrr;)rnamerrr __delattr__szLazyProxy.__delattr__cCs|jdk r|jt|j|S)N)r2getattrr;)rrYrrr __getattr__s zLazyProxy.__getattr__cCst|j||dS)N)setattrr;)rrYr;rrrr6szLazyProxy.__setattr__cCs |j|=dS)N)r;)rr=rrr __delitem__ szLazyProxy.__delitem__cCs |j|S)N)r;)rr=rrr __getitem__ szLazyProxy.__getitem__cCs||j|<dS)N)r;)rr=r;rrr __setitem__szLazyProxy.__setitem__cCs t|jf|jd|ji|jS)Nr3)r,r-r.r1r/)rrrr__copy__szLazyProxy.__copy__cCsDddlm}t||j|f||j|d||j|i||j|S)Nr)deepcopyr3)copyrbr,r-r.r1r/)rZmemorbrrr __deepcopy__s   zLazyProxy.__deepcopy__N)$r(r)r*r+ __slots__rpropertyr;r>r@rBrDrFrHrIrKrLrMrNrOrPrQrRrSrTrUrVrWrZr\r6r^r_r`rardrrrrr,s@" r,cseZdZdZd)fdd ZddZddZdd ZeZd d Z d d Z ddZ e Z dZ ddZddZddZddZddZddZddZdd ZeZd!d"Zd#d$Zd%d&ZeZd'd(ZesejjZejj Z!Z"S)*NullTranslationsNcsNi|_dd|_tt|j|dttdt|ddg|_|j |_ i|_ dS)aInitialize a simple translations class which is not backed by a real catalog. Behaves similar to gettext.NullTranslations but also offers Babel's on *gettext methods (e.g. 'dgettext()'). :param fp: a file-like object (ignored in this class) cSs t|dkS)N)int)nrrr3z+NullTranslations.__init__..)fpNrY) _catalogpluralsuperrgrlistfilterr[filesDEFAULT_DOMAINdomain_domains)rrm) __class__rrr(s  zNullTranslations.__init__cCs|j|||S)zULike ``gettext()``, but look the message up in the specified domain. )rvgetgettext)rrumessagerrrdgettext9szNullTranslations.dgettextcCs|j|||S)zVLike ``lgettext()``, but look the message up in the specified domain. )rvrxZlgettext)rrurzrrr ldgettext?szNullTranslations.ldgettextcCs|j|||S)zVLike ``ugettext()``, but look the message up in the specified domain. )rvrxugettext)rrurzrrr udgettextEszNullTranslations.udgettextcCs|j|||||S)zVLike ``ngettext()``, but look the message up in the specified domain. )rvrxngettext)rrusingularronumrrr dngettextMszNullTranslations.dngettextcCs|j|||||S)zWLike ``lngettext()``, but look the message up in the specified domain. )rvrxZ lngettext)rrurrorrrr ldngettextSszNullTranslations.ldngettextcCs|j|||||S)zVLike ``ungettext()`` but look the message up in the specified domain. )rvrx ungettext)rrurrorrrr udngettextYszNullTranslations.udngettextz%s%scCsj|j||f}t}|j||}||krB|jr>|j||S|S|jrTt||jS|jrft||jS|S)aLook up the `context` and `message` id in the catalog and return the corresponding message string, as an 8-bit string encoded with the catalog's charset encoding, if known. If there is no entry in the catalog for the `message` id and `context` , and a fallback has been set, the look up is forwarded to the fallback's ``pgettext()`` method. Otherwise, the `message` id is returned. ) CONTEXT_ENCODINGr5rnrx _fallbackpgettext_output_charsetr_charset)rcontextrz ctxt_msg_idmissingtmsgrrrrhs  zNullTranslations.pgettextcCsb|j||f}t}|j||}||krB|jr>|j||S|S|jrT||jS|t S)zEquivalent to ``pgettext()``, but the translation is returned in the preferred system encoding, if no other encoding was explicitly set with ``bind_textdomain_codeset()``. ) rr5rnrxr lpgettextrencodergetpreferredencoding)rrrzrrrrrrr~s zNullTranslations.lpgettextc Cs|j||f}y<|j|||f}|jr6t||jS|jrHt||jS|Stk r|jrr|j||||S|dkr~|S|SYnXdS)a^Do a plural-forms lookup of a message id. `singular` is used as the message id for purposes of lookup in the catalog, while `num` is used to determine which plural form to use. The returned message string is an 8-bit string encoded with the catalog's charset encoding, if known. If the message id for `context` is not found in the catalog, and a fallback is specified, the request is forwarded to the fallback's ``npgettext()`` method. Otherwise, when ``num`` is 1 ``singular`` is returned, and ``plural`` is returned in all other cases. rhN) rrnrorrrKeyErrorr npgettext)rrrrorrrrrrrs   zNullTranslations.npgettextc Cs|j||f}y4|j|||f}|jr6||jS|tStk r~|jrj|j ||||S|dkrv|S|SYnXdS)zEquivalent to ``npgettext()``, but the translation is returned in the preferred system encoding, if no other encoding was explicitly set with ``bind_textdomain_codeset()``. rhN) rrnrorrrrrr lnpgettext)rrrrorrrrrrrs zNullTranslations.lnpgettextcCsJ|j||f}t}|j||}||krF|jr>|j||St|S|S)asLook up the `context` and `message` id in the catalog and return the corresponding message string, as a Unicode string. If there is no entry in the catalog for the `message` id and `context`, and a fallback has been set, the look up is forwarded to the fallback's ``upgettext()`` method. Otherwise, the `message` id is returned. )rr5rnrxr upgettextr )rrrzctxt_message_idrrrrrrszNullTranslations.upgettextc Csr|j||f}y|j|||f}WnFtk rl|jrN|j||||S|dkr`t|}nt|}YnX|S)a$Do a plural-forms lookup of a message id. `singular` is used as the message id for purposes of lookup in the catalog, while `num` is used to determine which plural form to use. The returned message string is a Unicode string. If the message id for `context` is not found in the catalog, and a fallback is specified, the request is forwarded to the fallback's ``unpgettext()`` method. Otherwise, when `num` is 1 `singular` is returned, and `plural` is returned in all other cases. rh)rrnrorr unpgettextr )rrrrorrrrrrrs  zNullTranslations.unpgettextcCs|j||||S)zVLike `pgettext()`, but look the message up in the specified `domain`. )rvrxr)rrurrzrrr dpgettextszNullTranslations.dpgettextcCs|j||||S)zWLike `upgettext()`, but look the message up in the specified `domain`. )rvrxr)rrurrzrrr udpgettextszNullTranslations.udpgettextcCs|j||||S)zEquivalent to ``dpgettext()``, but the translation is returned in the preferred system encoding, if no other encoding was explicitly set with ``bind_textdomain_codeset()``. )rvrxr)rrurrzrrr ldpgettextszNullTranslations.ldpgettextcCs|j||||||S)zWLike ``npgettext``, but look the message up in the specified `domain`. )rvrxr)rrurrrorrrr dnpgettextszNullTranslations.dnpgettextcCs|j||||||S)zXLike ``unpgettext``, but look the message up in the specified `domain`. )rvrxr)rrurrrorrrr udnpgettextszNullTranslations.udnpgettextcCs|j||||||S)zEquivalent to ``dnpgettext()``, but the translation is returned in the preferred system encoding, if no other encoding was explicitly set with ``bind_textdomain_codeset()``. )rvrxr)rrurrrorrrr ldnpgettextszNullTranslations.ldnpgettext)N)#r(r)r*rtrr{r|r~Z dugettextrrrZ dungettextrrrrrrrrrZ dupgettextrrrZ dunpgettextrr ryrgr}rr __classcell__rr)rwrrg$s8rgcsbeZdZdZdZdfdd Zes2ejjZ ejj Z e dddZ dd Zdd d Zd dZZS) Translationsz&An extended translation catalog class.ZmessagesNcs"tt|j|d|p|j|_dS)zInitialize the translations catalog. :param fp: the file-like object the translation should be read from :param domain: the message domain (default: 'messages') )rmN)rprrrtru)rrmru)rwrrrszTranslations.__init__c Csn|dk r*t|ttfs|g}dd|D}|s4|j}t|||}|sLtSt|d}|||dSQRXdS)apLoad 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 (default: 'messages') NcSsg|] }t|qSr)rG).0rrrr 4sz%Translations.load..rb)rmru) isinstancerqtuplertryfindrgopen)clsdirnameZlocalesrufilenamermrrrload's  zTranslations.loadcCsdt|j|jdfS)Nz <%s: "%s">zproject-id-version)typer(Z_inforx)rrrr__repr__=s zTranslations.__repr__TcCsbt|d|j}|r&||jkr&||S|j|}|rJ|dk rJ||n||||j|<|S)a!Add the given translations to the catalog. If the domain of the translations is different than that of the current catalog, they are added as a catalog that is only accessible by the various ``d*gettext`` functions. :param translations: the `Translations` instance with the messages to add :param merge: whether translations for message domains that have already been added should be merged with the existing translations ruN)r[rtrumergervrxZ add_fallback)r translationsrruZexistingrrraddAs       zTranslations.addcCs6t|tjr2|j|jt|tr2|j|j|S)a0Merge the given translations into the catalog. Message translations in the specified catalog override any messages with the same identifier in the existing catalog. :param translations: the `Translations` instance with the messages to merge )rryGNUTranslationsrnupdaterrsextend)rrrrrr[s  zTranslations.merge)NN)NNN)T)r(r)r*r+rtrr ryrr}rr classmethodrrrrrrr)rwrrs   r)r+ryrZ babel.corerZ babel.datesrrrrZ babel.numbersrrr r r Z babel._compatr r rr5rr,rgrrrrrr s k r