Your IP : 216.73.216.196


Current Path : /opt/alt/python35/lib/python3.5/site-packages/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/__pycache__/speaklater.cpython-35.opt-1.pyc



M�L`�@sfdZdd�Zdd�Zdd�ZGdd�de�Zed	krbd
dlZej�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.
cCs
t|t�S)z,Checks if the given object is a lazy string.)�
isinstance�_LazyString)�obj�r�;/opt/alt/python35/lib/python3.5/site-packages/speaklater.py�is_lazy_stringFsrcOst|||�S)z1Creates a lazy string by invoking func with args.)r)Z__func�args�kwargsrrr�make_lazy_stringKsr	cs�fdd�}|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'
    cs t|�r|St��|�S)N)rr	)�string)�lookup_funcrr�lazy_gettext_sz'make_lazy_gettext.<locals>.lazy_gettextr)rrr)rr�make_lazy_gettextPsr
c@sfeZdZdZd<Zdd�Zedd��Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Z d;S)=rz�Class 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�_kwargscCs||_||_||_dS)N)rrr)�self�funcrrrrr�__init__ns		z_LazyString.__init__cCs|j|j|j�S)N)rrr)�xrrr�<lambda>ssz_LazyString.<lambda>cCs
||jkS)N)�value)r�keyrrr�__contains__usz_LazyString.__contains__cCs
t|j�S)N)�boolr)rrrr�__nonzero__xsz_LazyString.__nonzero__cCs
tt�S)N)�dir�unicode)rrrr�__dir__{sz_LazyString.__dir__cCs
t|j�S)N)�iterr)rrrr�__iter__~sz_LazyString.__iter__cCs
t|j�S)N)�lenr)rrrr�__len__�sz_LazyString.__len__cCs
t|j�S)N)�strr)rrrr�__str__�sz_LazyString.__str__cCs
t|j�S)N)rr)rrrr�__unicode__�sz_LazyString.__unicode__cCs|j|S)N)r)r�otherrrr�__add__�sz_LazyString.__add__cCs||jS)N)r)rr%rrr�__radd__�sz_LazyString.__radd__cCs|j|S)N)r)rr%rrr�__mod__�sz_LazyString.__mod__cCs||jS)N)r)rr%rrr�__rmod__�sz_LazyString.__rmod__cCs|j|S)N)r)rr%rrr�__mul__�sz_LazyString.__mul__cCs||jS)N)r)rr%rrr�__rmul__�sz_LazyString.__rmul__cCs
|j|kS)N)r)rr%rrr�__lt__�sz_LazyString.__lt__cCs
|j|kS)N)r)rr%rrr�__le__�sz_LazyString.__le__cCs
|j|kS)N)r)rr%rrr�__eq__�sz_LazyString.__eq__cCs
|j|kS)N)r)rr%rrr�__ne__�sz_LazyString.__ne__cCs
|j|kS)N)r)rr%rrr�__gt__�sz_LazyString.__gt__cCs
|j|kS)N)r)rr%rrr�__ge__�sz_LazyString.__ge__cCs&|dkr|j�St|j|�S)NZ__members__)r�getattrr)r�namerrr�__getattr__�s
z_LazyString.__getattr__cCs|j|j|jfS)N)rrr)rrrr�__getstate__�sz_LazyString.__getstate__cCs|\|_|_|_dS)N)rrr)r�tuprrr�__setstate__�sz_LazyString.__setstate__cCs|j|S)N)r)rrrrr�__getitem__�sz_LazyString.__getitem__cCs|S)Nr)rrrr�__copy__�sz_LazyString.__copy__cCs<ydt|j�SWn tk
r7d|jjSYnXdS)N�lz<%s broken>)�reprr�	Exception�	__class__�__name__)rrrr�__repr__�s
z_LazyString.__repr__N)rrr)!r>�
__module__�__qualname__�__doc__�	__slots__r�propertyrrrrrr!r#r$r&r'r(r)r*r+r,r-r.r/r0r1r4r5r7r8r9r?rrrrrfs:r�__main__�N)	rBrr	r
�objectrr>ZdoctestZtestmodrrrr�<module>Cs`