%PDF- %PDF-
| Direktori : /lib64/python2.7/site-packages/zmq/eventloop/minitornado/ |
| Current File : //lib64/python2.7/site-packages/zmq/eventloop/minitornado/util.pyo |
�
+�{Wc @� s� d Z d d l m Z m Z m Z m Z d d l Z e d e d � � sa d � Z e
Z e
Z n d � Z e
Z e Z d � Z e Z e j d k r� d d Un d
d Ud � Z d e f d
� � YZ d � Z d S( 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 ( t absolute_importt divisiont print_functiont with_statementNt c C� s | S( N( ( t s( ( sD /usr/lib64/python2.7/site-packages/zmq/eventloop/minitornado/util.pyt u s c C� s
| j d � S( Nt unicode_escape( t decode( R ( ( sD /usr/lib64/python2.7/site-packages/zmq/eventloop/minitornado/util.pyR s c C� s� t | t � r- t t k r- | j d � } n | j d � d k rR t | d d � S| j d � } t d j | d � d d | d g d � } y t | | d � SWn% t
k
r� t d | d � � n Xd S( 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
s utf-8t .i i����s No module named %sN( t
isinstancet unicode_typet strt encodet countt
__import__t Nonet splitt joint getattrt AttributeErrort ImportError( t namet partst obj( ( sD /usr/lib64/python2.7/site-packages/zmq/eventloop/minitornado/util.pyt
import_object% s ,
i s�
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
c C� s2 t | d � r | j S| j r* | j d Sd Sd S( sL Provides 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.
t errnoi N( t hasattrR t argsR ( t e( ( sD /usr/lib64/python2.7/site-packages/zmq/eventloop/minitornado/util.pyt errno_from_exceptiona s
t Configurablec B� s� e Z d Z d Z d Z d � Z e d � � Z e d � � Z d � Z
e d � � Z e d � � Z e d � � Z
e d � � Z RS(
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__``.
c O� s� | j � } i } | | k rI | j � } | j rO | j | j � qO n | } | j | � t t | � j | � } | j | | � | S( N( t configurable_baset configured_classt _Configurable__impl_kwargst updatet superR t __new__t
initialize( t clsR t kwargst baset init_kwargst implt instance( ( sD /usr/lib64/python2.7/site-packages/zmq/eventloop/minitornado/util.pyR% � s
c C� s
t � � d S( 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( t NotImplementedError( R'