/opt/imunify360/venv/lib/python3.11/site-packages/__pycache__
Edit: /opt/imunify360/venv/lib/python3.11/site-packages/__pycache__/speaklater.cpython-311.pyc (9161B)
]j` n d Z d Zd Zd Z G d de Zedk rddlZ ej dS dS ) a
speaklater
~~~~~~~~~~
A module that provides lazy strings for translations. Basically you
get an object that appears to be a string but changes the value every
time the value is evaluated based on a callable you provide.
For example you can have a global `lazy_gettext` function that returns
a lazy string with the value of the current set language.
Example:
>>> from speaklater import make_lazy_string
>>> sval = u'Hello World'
>>> string = make_lazy_string(lambda: sval)
This lazy string will evaluate to the value of the `sval` variable.
>>> string
lu'Hello World'
>>> unicode(string)
u'Hello World'
>>> string.upper()
u'HELLO WORLD'
If you change the value, the lazy string will change as well:
>>> sval = u'Hallo Welt'
>>> string.upper()
u'HALLO WELT'
This is especially handy when combined with a thread local and gettext
translations or dicts of translatable strings:
>>> from speaklater import make_lazy_gettext
>>> from threading import local
>>> l = local()
>>> l.translations = {u'Yes': 'Ja'}
>>> lazy_gettext = make_lazy_gettext(lambda: l.translations.get)
>>> yes = lazy_gettext(u'Yes')
>>> print yes
Ja
>>> l.translations[u'Yes'] = u'Si'
>>> print yes
Si
Lazy strings are no real strings so if you pass this sort of string to
a function that performs an instance check, it will fail. In that case
you have to explicitly convert it with `unicode` and/or `string` depending
on what string type the lazy string encapsulates.
To check if a string is lazy, you can use the `is_lazy_string` function:
>>> from speaklater import is_lazy_string
>>> is_lazy_string(u'yes')
False
>>> is_lazy_string(yes)
True
New in version 1.2: It's now also possible to pass keyword arguments to
the callback used with `make_lazy_string`.
:copyright: (c) 2010 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
c , t | t S )z,Checks if the given object is a lazy string.)
isinstance_LazyString)objs j/builddir/build/BUILD/imunify360-venv-2.6.3/opt/imunify360/venv/lib/python3.11/site-packages/speaklater.pyis_lazy_stringr F s c;''' c $ t | || S )z1Creates a lazy string by invoking func with args.)r )__funcargskwargss r make_lazy_stringr
K s vtV,,,r c fd}|S )aP Creates a lazy gettext function dispatches to a gettext
function as returned by `lookup_func`.
Example:
>>> translations = {u'Yes': u'Ja'}
>>> lazy_gettext = make_lazy_gettext(lambda: translations.get)
>>> x = lazy_gettext(u'Yes')
>>> x
lu'Ja'
>>> translations[u'Yes'] = u'Si'
>>> x
lu'Si'
c V t | r| S t | S N)r r
)stringlookup_funcs r lazy_gettextz'make_lazy_gettext.
.lazy_gettext_ s. &!! M
v666r )r r s ` r make_lazy_gettextr P s$ 7 7 7 7 7 r c e Zd ZdZdZd Z ed Zd Zd Z d Z
d Zd Zd
Z
d Zd Zd
Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z dS )r zClass for strings created by a function call.
The proxy implementation attempts to be as complete as possible, so that
the lazy objects should mostly work as expected, for example for sorting.
_func_args_kwargsc 0 || _ || _ || _ d S r r )selffuncr r s r __init__z_LazyString.__init__n s
r c 0 | j | j i | j S r r )xs r z_LazyString.s s wqw=19== r c || j v S r valuer keys r __contains__z_LazyString.__contains__u s dj r c * t | j S r )boolr$ r s r __nonzero__z_LazyString.__nonzero__x DJr c * t t S r )dirunicoder* s r __dir__z_LazyString.__dir__{ s 7||r c * t | j S r )iterr$ r* s r __iter__z_LazyString.__iter__~ r, r c * t | j S r )lenr$ r* s r __len__z_LazyString.__len__ 4:r c * t | j S r )strr$ r* s r __str__z_LazyString.__str__ r7 r c * t | j S r )r/ r$ r* s r __unicode__z_LazyString.__unicode__ s tz"""r c | j |z S r r# r others r __add__z_LazyString.__add__ zE!!r c || j z S r r# r> s r __radd__z_LazyString.__radd__ tz!!r c | j |z S r r# r> s r __mod__z_LazyString.__mod__ rA r c || j z S r r# r> s r __rmod__z_LazyString.__rmod__ rD r c | j |z S r r# r> s r __mul__z_LazyString.__mul__ rA r c || j z S r r# r> s r __rmul__z_LazyString.__rmul__ rD r c | j |k S r r# r> s r __lt__z_LazyString.__lt__ zE!!r c | j |k S r r# r> s r __le__z_LazyString.__le__ zU""r c | j |k S r r# r> s r __eq__z_LazyString.__eq__ rR r c | j |k S r r# r> s r __ne__z_LazyString.__ne__ rR r c | j |k S r r# r> s r __gt__z_LazyString.__gt__ rO r c | j |k S r r# r> s r __ge__z_LazyString.__ge__ rR r c ` |dk r| S t | j | S )N__members__)r0 getattrr$ )r names r __getattr__z_LazyString.__getattr__ s- = <<>>!tz4(((r c * | j | j | j fS r r r* s r __getstate__z_LazyString.__getstate__ s z4:t|33r c 0 |\ | _ | _ | _ d S r r )r tups r __setstate__z_LazyString.__setstate__ s /2,
DJr c | j | S r r# r% s r __getitem__z_LazyString.__getitem__ s z#r c | S r r r* s r __copy__z_LazyString.__copy__ s r c p dt | j z S # t $ r d| j j z cY S w xY w)Nlz<%s broken>)reprr$ Exception __class____name__r* s r __repr__z_LazyString.__repr__ sM ;dj)))) ; ; ; 4>#::::: ;s 55N)!rn
__module____qualname____doc__ __slots__r propertyr$ r' r+ r0 r3 r6 r: r<