cf`ndZdZdZdZGddeZedkrddlZejdSdS) 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|tS)z,Checks if the given object is a lazy string.) isinstance _LazyString)objs j/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/speaklater.pyis_lazy_stringrFs c; ' ''c$t|||S)z1Creates a lazy string by invoking func with args.)r)__funcargskwargss rmake_lazy_stringr Ks vtV , ,,rcfd}|S)aPCreates 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' cVt|r|St|SN)rr )string lookup_funcs r lazy_gettextz'make_lazy_gettext..lazy_gettext_s. & ! ! M v666r)rrs` rmake_lazy_gettextrPs$77777 rceZdZdZdZdZedZdZdZ dZ dZ d Z d Z d Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dS)rzClass 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_kwargsc0||_||_||_dSrr)selffuncr r s r__init__z_LazyString.__init__ns   rc0|j|ji|jSrr)xs rz_LazyString.sswqw=19==rc||jvSrvaluerkeys r __contains__z_LazyString.__contains__usdj  rc*t|jSr)boolr$rs r __nonzero__z_LazyString.__nonzero__xDJrc*ttSr)dirunicoder*s r__dir__z_LazyString.__dir__{s7||rc*t|jSr)iterr$r*s r__iter__z_LazyString.__iter__~r,rc*t|jSr)lenr$r*s r__len__z_LazyString.__len__4:rc*t|jSr)strr$r*s r__str__z_LazyString.__str__r7rc*t|jSr)r/r$r*s r __unicode__z_LazyString.__unicode__stz"""rc|j|zSrr#rothers r__add__z_LazyString.__add__zE!!rc||jzSrr#r>s r__radd__z_LazyString.__radd__tz!!rc|j|zSrr#r>s r__mod__z_LazyString.__mod__rArc||jzSrr#r>s r__rmod__z_LazyString.__rmod__rDrc|j|zSrr#r>s r__mul__z_LazyString.__mul__rArc||jzSrr#r>s r__rmul__z_LazyString.__rmul__rDrc|j|kSrr#r>s r__lt__z_LazyString.__lt__zE!!rc|j|kSrr#r>s r__le__z_LazyString.__le__zU""rc|j|kSrr#r>s r__eq__z_LazyString.__eq__rRrc|j|kSrr#r>s r__ne__z_LazyString.__ne__rRrc|j|kSrr#r>s r__gt__z_LazyString.__gt__rOrc|j|kSrr#r>s r__ge__z_LazyString.__ge__rRrc`|dkr|St|j|S)N __members__)r0getattrr$)rnames r __getattr__z_LazyString.__getattr__s- = <<>> !tz4(((rc*|j|j|jfSrrr*s r __getstate__z_LazyString.__getstate__sz4:t|33rc0|\|_|_|_dSrr)rtups r __setstate__z_LazyString.__setstate__s/2, DJ rc|j|Srr#r%s r __getitem__z_LazyString.__getitem__sz#rc|Srrr*s r__copy__z_LazyString.__copy__s rcp dt|jzS#t$rd|jjzcYSwxYw)Nlz <%s broken>)reprr$ Exception __class____name__r*s r__repr__z_LazyString.__repr__sM ;dj))) ) ; ; ; 4>#:: : : : ;s 55N)!rn __module__ __qualname____doc__ __slots__rpropertyr$r'r+r0r3r6r:r<r@rCrFrHrJrLrNrQrTrVrXrZr_rardrfrhrorrrrrfs .I H== > >E!!!      ###"""""""""""""""""""""#########"""###))) 444333;;;;;rr__main__N) rrrr robjectrrndoctesttestmodrrrrzsAAH((( --- ,];];];];];&];];];@ zNNNGOr