%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib64/python2.7/site-packages/tornado/
Upload File :
Create Path :
Current File : //usr/lib64/python2.7/site-packages/tornado/util.pyo

�
��L]c@�s�dZddlmZmZmZmZddlZddlZddlZddl	Z	ddl
Z
yeWnek
r�e
ZnXdefd��YZdefd��YZeded��s�d	�ZeZeZnd
�ZeZeZd�ZeZe	jdkrd
dUnddUd�Zdefd��YZdefd��YZ d�Z!d�Z"ej#j$d�s�ej#j$d�dkr�e"Z%nLyddl&m'Z%Wn5e(k
r�ej#j$d�dkr��ne"Z%nXd�Z)dS(s�Miscellaneous utility functions and classes.

This module is used internally by Tornado.  It is not necessarily expected
that the functions and classes defined here will be useful to other
applications, but they are documented here in case they are.

The one public-facing part of this module is the `Configurable` class
and its `~Configurable.configure` method, which becomes a part of the
interface of its subclasses, including `.AsyncHTTPClient`, `.IOLoop`,
and `.Resolver`.
i(tabsolute_importtdivisiontprint_functiontwith_statementNt
ObjectDictcB�s eZdZd�Zd�ZRS(sKMakes a dictionary behave like an object, with attribute-style access.
    cC�s0y||SWntk
r+t|��nXdS(N(tKeyErrortAttributeError(tselftname((s2/usr/lib64/python2.7/site-packages/tornado/util.pyt__getattr__s
cC�s|||<dS(N((RRtvalue((s2/usr/lib64/python2.7/site-packages/tornado/util.pyt__setattr__%s(t__name__t
__module__t__doc__R	R(((s2/usr/lib64/python2.7/site-packages/tornado/util.pyRs	tGzipDecompressorcB�s;eZdZd�Zdd�Zed��Zd�ZRS(s�Streaming gzip decompressor.

    The interface is like that of `zlib.decompressobj` (without some of the
    optional arguments, but it understands gzip headers and checksums.
    cC�stjdtj�|_dS(Ni(tzlibt
decompressobjt	MAX_WBITS(R((s2/usr/lib64/python2.7/site-packages/tornado/util.pyt__init__/scC�s|jj||�S(s�Decompress a chunk, returning newly-available data.

        Some data may be buffered for later processing; `flush` must
        be called when there is no more input data to ensure that
        all data was processed.

        If ``max_length`` is given, some input data may be left over
        in ``unconsumed_tail``; you must retrieve this value and pass
        it back to a future call to `decompress` if it is not empty.
        (Rt
decompress(RR
t
max_length((s2/usr/lib64/python2.7/site-packages/tornado/util.pyR5scC�s
|jjS(s1Returns the unconsumed portion left over
        (Rtunconsumed_tail(R((s2/usr/lib64/python2.7/site-packages/tornado/util.pyRBscC�s
|jj�S(s�Return any remaining buffered data not yet returned by decompress.

        Also checks for errors such as truncated input.
        No other methods may be called on this object after `flush`.
        (Rtflush(R((s2/usr/lib64/python2.7/site-packages/tornado/util.pyRHsN(	RR
RRtNoneRtpropertyRR(((s2/usr/lib64/python2.7/site-packages/tornado/util.pyR)s
	
tcC�s|S(N((ts((s2/usr/lib64/python2.7/site-packages/tornado/util.pytuWscC�s
|jd�S(Ntunicode_escape(tdecode(R((s2/usr/lib64/python2.7/site-packages/tornado/util.pyR\scC�s�t|t�r-ttk	r-|jd�}n|jd�dkrRt|dd�S|jd�}tdj|d �dd|dgd�}yt	||d�SWn%t
k
r�td|d��nXdS(sImports an object by name.

    import_object('x') is equivalent to 'import x'.
    import_object('x.y.z') is equivalent to 'from x.y import z'.

    >>> import tornado.escape
    >>> import_object('tornado.escape') is tornado.escape
    True
    >>> import_object('tornado.escape.utf8') is tornado.escape.utf8
    True
    >>> import_object('tornado') is tornado
    True
    >>> import_object('tornado.missing_module')
    Traceback (most recent call last):
        ...
    ImportError: No module named missing_module
    sutf-8t.ii����sNo module named %sN(t
isinstancetunicode_typetstrtencodetcountt
__import__RtsplittjointgetattrRtImportError(Rtpartstobj((s2/usr/lib64/python2.7/site-packages/tornado/util.pyt
import_objectds,
is�
def raise_exc_info(exc_info):
    raise exc_info[1].with_traceback(exc_info[2])

def exec_in(code, glob, loc=None):
    if isinstance(code, str):
        code = compile(code, '<string>', 'exec', dont_inherit=True)
    exec(code, glob, loc)
sh
def raise_exc_info(exc_info):
    raise exc_info[0], exc_info[1], exc_info[2]

def exec_in(code, glob, loc=None):
    if isinstance(code, basestring):
        # exec(string) inherits the caller's future imports; compile
        # the string first to prevent that.
        code = compile(code, '<string>', 'exec', dont_inherit=True)
    exec code in glob, loc
cC�s2t|d�r|jS|jr*|jdSdSdS(sLProvides the errno from an Exception object.

    There are cases that the errno attribute was not set so we pull
    the errno out of the args but if someone instantiates an Exception
    without any args you will get a tuple error. So this function
    abstracts all that behavior to give you a safe way to get the
    errno.
    terrnoiN(thasattrR-targsR(te((s2/usr/lib64/python2.7/site-packages/tornado/util.pyterrno_from_exception�s

	tConfigurablecB�s�eZdZd	Zd	Zd�Zed��Zed��Z	d�Z
ed��Zed��Zed��Z
ed��ZRS(
s�Base class for configurable interfaces.

    A configurable interface is an (abstract) class whose constructor
    acts as a factory function for one of its implementation subclasses.
    The implementation subclass as well as optional keyword arguments to
    its initializer can be set globally at runtime with `configure`.

    By using the constructor as the factory method, the interface
    looks like a normal class, `isinstance` works as usual, etc.  This
    pattern is most useful when the choice of implementation is likely
    to be a global decision (e.g. when `~select.epoll` is available,
    always use it instead of `~select.select`), or when a
    previously-monolithic class has been split into specialized
    subclasses.

    Configurable subclasses must define the class methods
    `configurable_base` and `configurable_default`, and use the instance
    method `initialize` instead of ``__init__``.
    cO�s�|j�}i}||krI|j�}|jrO|j|j�qOn|}|j|�tt|�j|�}|j||�|S(N(tconfigurable_basetconfigured_classt_Configurable__impl_kwargstupdatetsuperR2t__new__t
initialize(tclsR/tkwargstbasetinit_kwargstimpltinstance((s2/usr/lib64/python2.7/site-packages/tornado/util.pyR8�s	
cC�s
t��dS(s�Returns the base class of a configurable hierarchy.

        This will normally return the class in which it is defined.
        (which is *not* necessarily the same as the cls classmethod parameter).
        N(tNotImplementedError(R:((s2/usr/lib64/python2.7/site-packages/tornado/util.pyR3�scC�s
t��dS(sBReturns the implementation class to be used if none is configured.N(R@(R:((s2/usr/lib64/python2.7/site-packages/tornado/util.pytconfigurable_default�scC�sdS(s�Initialize a `Configurable` subclass instance.

        Configurable classes should use `initialize` instead of ``__init__``.

        .. versionchanged:: 4.2
           Now accepts positional arguments in addition to keyword arguments.
        N((R((s2/usr/lib64/python2.7/site-packages/tornado/util.pyR9�scK�su|j�}t|ttf�r0t|�}n|dk	r_t||�r_td|��n||_||_	dS(s�Sets the class to use when the base class is instantiated.

        Keyword arguments will be saved and added to the arguments passed
        to the constructor.  This can be used to set global defaults for
        some parameters.
        sInvalid subclass of %sN(
R3R R!tbytesR,Rt
issubclasst
ValueErrort_Configurable__impl_classR5(R:R>R;R<((s2/usr/lib64/python2.7/site-packages/tornado/util.pyt	configure�s	cC�s4|j�}|jdkr-|j�|_n|jS(s'Returns the currently configured class.N(R3RERRA(R:R<((s2/usr/lib64/python2.7/site-packages/tornado/util.pyR4scC�s|j�}|j|jfS(N(R3RER5(R:R<((s2/usr/lib64/python2.7/site-packages/tornado/util.pyt_save_configuration	scC�s*|j�}|d|_|d|_dS(Nii(R3RER5(R:tsavedR<((s2/usr/lib64/python2.7/site-packages/tornado/util.pyt_restore_configurations
N(RR
RRRER5R8tclassmethodR3RAR9RFR4RGRI(((s2/usr/lib64/python2.7/site-packages/tornado/util.pyR2�s				tArgReplacercB�s,eZdZd�Zdd�Zd�ZRS(s�Replaces one value in an ``args, kwargs`` pair.

    Inspects the function signature to find an argument by name
    whether it is passed by position or keyword.  For use in decorators
    and similar wrappers.
    cC�sO||_y%tj|�jj|j�|_Wntk
rJd|_nXdS(N(Rtinspectt
getargspecR/tindextarg_posRDR(RtfuncR((s2/usr/lib64/python2.7/site-packages/tornado/util.pyRs
	%
cC�sF|jdk	r/t|�|jkr/||jS|j|j|�SdS(s�Returns the old value of the named argument without replacing it.

        Returns ``default`` if the argument is not present.
        N(RORtlentgetR(RR/R;tdefault((s2/usr/lib64/python2.7/site-packages/tornado/util.pyt
get_old_value$s$cC�sy|jdk	rMt|�|jkrM||j}t|�}|||j<n|j|j�}|||j<|||fS(s�Replace the named argument in ``args, kwargs`` with ``new_value``.

        Returns ``(old_value, args, kwargs)``.  The returned ``args`` and
        ``kwargs`` objects may not be the same as the input objects, or
        the input objects may be mutated.

        If the named argument was not found, ``new_value`` will be added
        to ``kwargs`` and None will be returned as ``old_value``.
        N(RORRQtlistRRR(Rt	new_valueR/R;t	old_value((s2/usr/lib64/python2.7/site-packages/tornado/util.pytreplace.s
$

N(RR
RRRRTRX(((s2/usr/lib64/python2.7/site-packages/tornado/util.pyRKs	
cC�s+|j|j|jdddtd�S(s<Equivalent to td.total_seconds() (introduced in python 2.7).iii
ii@Bi@B(tmicrosecondstsecondstdaystfloat(ttd((s2/usr/lib64/python2.7/site-packages/tornado/util.pyttimedelta_to_secondsDscC�s�tjd|�}tjd|�}x4tt|��D] }||||dA||<q7Wt|d�rt|j�S|j�SdS(sQWebsocket masking function.

    `mask` is a `bytes` object of length 4; `data` is a `bytes` object of any length.
    Returns a `bytes` object of the same length as `data` with the mask applied
    as specified in section 5.3 of RFC 6455.

    This pure-python implementation may be replaced by an optimized version when available.
    tBittobytesN(tarraytxrangeRQR.R`ttostring(tmasktdatatunmaskedti((s2/usr/lib64/python2.7/site-packages/tornado/util.pyt_websocket_mask_pythonIs	
tTORNADO_NO_EXTENSIONtTORNADO_EXTENSIONt0(twebsocket_maskt1cC�sddl}|j�S(Ni(tdoctesttDocTestSuite(Rn((s2/usr/lib64/python2.7/site-packages/tornado/util.pytdoctestsls(i(*Rt
__future__RRRRRaRLtostsysRRbt	NameErrortrangetdictRtobjectRR ttypeRR"R!tbasestring_typetunicodet
basestringR,RBt
bytes_typetversion_infoR1R2RKR^RhtenvironRRt_websocket_maskttornado.speedupsRlR)Rp(((s2/usr/lib64/python2.7/site-packages/tornado/util.pyt<module>sN"


-				"		c/			



Zerion Mini Shell 1.0