<s> from __future__ import unicode_literals <EOL> """<STR_LIT>""" <EOL> import functools <EOL> import inspect <EOL> import os <EOL> import sys <EOL> import time <EOL> import traceback <EOL> from tornado . ioloop import IOLoop <EOL> import motor <EOL> import motor . frameworks . tornado <EOL> import motor . motor_tornado <EOL> from motor . metaprogramming import ( <EOL> MotorAttributeFactory , <EOL> ReadOnlyPropertyDescriptor , <EOL> Unwrap ) <EOL> from gridfs . errors import * <EOL> from pymongo import * <EOL> from pymongo import member <EOL> from pymongo import son_manipulator <EOL> from pymongo import ssl_match_hostname <EOL> from pymongo . helpers import _unpack_response , _check_command_response <EOL> from pymongo . common import * <EOL> from pymongo . cursor import * <EOL> from pymongo . cursor import _QUERY_OPTIONS <EOL> from pymongo . errors import * <EOL> from pymongo . member import PRIMARY , SECONDARY , OTHER <EOL> from pymongo . read_preferences import * <EOL> from pymongo . son_manipulator import * <EOL> from pymongo . uri_parser import * <EOL> from pymongo . uri_parser import _partition , _rpartition <EOL> from pymongo import auth <EOL> from pymongo . auth import * <EOL> from pymongo . auth import _password_digest <EOL> from gridfs . grid_file import DEFAULT_CHUNK_SIZE , _SEEK_CUR , _SEEK_END <EOL> GridFile = None <EOL> have_gevent = False <EOL> from pymongo import GEOSPHERE , HASHED <EOL> from pymongo . pool import NO_REQUEST , NO_SOCKET_YET , SocketInfo , Pool , _closed <EOL> from pymongo . mongo_replica_set_client import _partition_node , Member , Monitor <EOL> def unwrap_synchro ( fn ) : <EOL> """<STR_LIT>""" <EOL> @ functools . wraps ( fn ) <EOL> def _unwrap_synchro ( * args , ** kwargs ) : <EOL> def _unwrap_obj ( obj ) : <EOL> if isinstance ( obj , Synchro ) : <EOL> return obj . delegate <EOL> else : <EOL> return obj <EOL> args = [ _unwrap_obj ( arg ) for arg in args ] <EOL> kwargs = dict ( [ <EOL> ( key , _unwrap_obj ( value ) ) for key , value in kwargs . items ( ) ] ) <EOL> return fn ( * args , ** kwargs ) <EOL> return _unwrap_synchro <EOL> def wrap_synchro ( fn ) : <EOL> """<STR_LIT>""" <EOL> @ functools . wraps ( fn ) <EOL> def _wrap_synchro ( * args , ** kwargs ) : <EOL> motor_obj = fn ( * args , ** kwargs ) <EOL> if isinstance ( motor_obj , motor . MotorCollection ) : <EOL> client = MongoClient ( delegate = motor_obj . database . connection ) <EOL> database = Database ( client , motor_obj . database . name ) <EOL> return Collection ( database , motor_obj . name ) <EOL> if isinstance ( motor_obj , motor . MotorDatabase ) : <EOL> client = MongoClient ( delegate = motor_obj . connection ) <EOL> return Database ( client , motor_obj . name ) <EOL> if isinstance ( motor_obj , motor . motor_tornado . MotorCommandCursor ) : <EOL> return CommandCursor ( motor_obj ) <EOL> if isinstance ( motor_obj , motor . motor_tornado . MotorCursor ) : <EOL> return Cursor ( motor_obj ) <EOL> if isinstance ( motor_obj , motor . MotorBulkOperationBuilder ) : <EOL> return BulkOperationBuilder ( motor_obj ) <EOL> if isinstance ( motor_obj , motor . MotorGridFS ) : <EOL> return GridFS ( motor_obj ) <EOL> if isinstance ( motor_obj , motor . MotorGridIn ) : <EOL> return GridIn ( None , delegate = motor_obj ) <EOL> if isinstance ( motor_obj , motor . MotorGridOut ) : <EOL> return GridOut ( None , delegate = motor_obj ) <EOL> if isinstance ( motor_obj , motor . motor_tornado . MotorGridOutCursor ) : <EOL> return GridOutCursor ( motor_obj ) <EOL> else : <EOL> return motor_obj <EOL> return _wrap_synchro <EOL> class Sync ( object ) : <EOL> def __init__ ( self , name , has_write_concern ) : <EOL> self . name = name <EOL> self . has_write_concern = has_write_concern <EOL> def __get__ ( self , obj , objtype ) : <EOL> async_method = getattr ( obj . delegate , self . name ) <EOL> return wrap_synchro ( unwrap_synchro ( obj . synchronize ( async_method ) ) ) <EOL> class WrapOutgoing ( object ) : <EOL> def __get__ ( self , obj , objtype ) : <EOL> name = self . name <EOL> def synchro_method ( * args , ** kwargs ) : <EOL> motor_method = getattr ( obj . delegate , name ) <EOL> return wrap_synchro ( motor_method ) ( * args , ** kwargs ) <EOL> return synchro_method <EOL> class SynchroProperty ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . name = None <EOL> def __get__ ( self , obj , objtype ) : <EOL> return getattr ( obj . delegate . delegate , self . name ) <EOL> def __set__ ( self , obj , val ) : <EOL> return setattr ( obj . delegate . delegate , self . name , val ) <EOL> class SynchroMeta ( type ) : <EOL> """<STR_LIT>""" <EOL> def __new__ ( cls , name , bases , attrs ) : <EOL> new_class = type . __new__ ( cls , name , bases , attrs ) <EOL> delegate_class = new_class . __delegate_class__ <EOL> if delegate_class : <EOL> delegated_attrs = { } <EOL> for klass in reversed ( inspect . getmro ( delegate_class ) ) : <EOL> delegated_attrs . update ( klass . __dict__ ) <EOL> for attrname , delegate_attr in delegated_attrs . items ( ) : <EOL> if attrname not in attrs : <EOL> if getattr ( <EOL> delegate_attr , '<STR_LIT>' , False ) : <EOL> sync_method = Sync ( <EOL> attrname , delegate_attr . has_write_concern ) <EOL> setattr ( new_class , attrname , sync_method ) <EOL> elif isinstance ( <EOL> delegate_attr , Unwrap ) : <EOL> sync_method = Sync ( <EOL> attrname , delegate_attr . prop . has_write_concern ) <EOL> setattr ( new_class , attrname , sync_method ) <EOL> elif getattr ( <EOL> delegate_attr , <EOL> '<STR_LIT>' , <EOL> False ) : <EOL> wrapper = WrapOutgoing ( ) <EOL> wrapper . name = attrname <EOL> setattr ( new_class , attrname , wrapper ) <EOL> elif isinstance ( <EOL> delegate_attr , <EOL> ReadOnlyPropertyDescriptor ) : <EOL> setattr ( new_class , attrname , delegate_attr ) <EOL> for name , attr in attrs . items ( ) : <EOL> if isinstance ( <EOL> attr , <EOL> ( MotorAttributeFactory , SynchroProperty , WrapOutgoing ) <EOL> ) : <EOL> attr . name = name <EOL> return new_class <EOL> class Synchro ( object ) : <EOL> """<STR_LIT>""" <EOL> __metaclass__ = SynchroMeta <EOL> __delegate_class__ = None <EOL> def __cmp__ ( self , other ) : <EOL> return cmp ( self . delegate , other . delegate ) <EOL> _BaseObject__set_slave_okay = SynchroProperty ( ) <EOL> _BaseObject__set_safe = SynchroProperty ( ) <EOL> def synchronize ( self , async_method ) : <EOL> """<STR_LIT>""" <EOL> @ functools . wraps ( async_method ) <EOL> def synchronized_method ( * args , ** kwargs ) : <EOL> if '<STR_LIT>' in kwargs : <EOL> safe = kwargs . pop ( '<STR_LIT>' ) <EOL> if not isinstance ( safe , bool ) : <EOL> raise TypeError ( '<STR_LIT>' % safe ) <EOL> kwargs [ '<STR_LIT:w>' ] = <NUM_LIT:1> if safe else <NUM_LIT:0> <EOL> @ functools . wraps ( async_method ) <EOL> def partial ( ) : <EOL> return async_method ( * args , ** kwargs ) <EOL> return IOLoop . current ( ) . run_sync ( partial ) <EOL> return synchronized_method <EOL> @ property <EOL> def safe ( self ) : <EOL> try : <EOL> safe , opts = self . delegate . delegate . _get_write_mode ( ) <EOL> return safe <EOL> except ( AttributeError , InvalidOperation ) : <EOL> return True <EOL> @ safe . setter <EOL> def safe ( self , value ) : <EOL> if value : <EOL> self . delegate . write_concern . pop ( '<STR_LIT:w>' , None ) <EOL> else : <EOL> self . delegate . write_concern [ '<STR_LIT:w>' ] = <NUM_LIT:0> <EOL> @ property <EOL> def slave_okay ( self ) : <EOL> motor_obj = self . delegate <EOL> pymongo_obj = motor_obj . delegate <EOL> pref = getattr ( motor_obj , '<STR_LIT>' , ReadPreference . PRIMARY ) <EOL> slave_okay = getattr ( pymongo_obj , '<STR_LIT>' , False ) <EOL> return ( pref != ReadPreference . PRIMARY ) or slave_okay <EOL> def __eq__ ( self , other ) : <EOL> return self . delegate == other . delegate <EOL> _get_write_mode = SynchroProperty ( ) <EOL> get_lasterror_options = SynchroProperty ( ) <EOL> class MongoClientBase ( Synchro ) : <EOL> _cache_credentials = SynchroProperty ( ) <EOL> get_default_database = WrapOutgoing ( ) <EOL> max_pool_size = SynchroProperty ( ) <EOL> max_write_batch_size = SynchroProperty ( ) <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> self . use_greenlets = False <EOL> self . auto_start_request = False <EOL> kwargs . pop ( '<STR_LIT>' , None ) <EOL> if '<STR_LIT>' not in kwargs and ( <EOL> kwargs . get ( '<STR_LIT>' ) not in ( None , [ ] , [ { } ] ) ) : <EOL> raise ConfigurationError ( ) <EOL> if '<STR_LIT>' not in kwargs and ( <EOL> '<STR_LIT>' in kwargs or '<STR_LIT>' in kwargs ) : <EOL> secondary = kwargs . pop ( '<STR_LIT>' , kwargs . pop ( '<STR_LIT>' , False ) ) <EOL> kwargs [ '<STR_LIT>' ] = ( <EOL> ReadPreference . SECONDARY_PREFERRED if secondary <EOL> else ReadPreference . PRIMARY ) <EOL> gle_opts = dict ( [ <EOL> ( k , v ) for k , v in kwargs . items ( ) <EOL> if k in SAFE_OPTIONS ] ) <EOL> if gle_opts and '<STR_LIT:w>' not in gle_opts : <EOL> kwargs [ '<STR_LIT:w>' ] = <NUM_LIT:1> <EOL> if '<STR_LIT>' in kwargs : <EOL> safe = kwargs . pop ( '<STR_LIT>' ) <EOL> if not safe : <EOL> kwargs . setdefault ( '<STR_LIT:w>' , <NUM_LIT:0> ) <EOL> self . delegate = kwargs . pop ( '<STR_LIT>' , None ) <EOL> if not self . delegate : <EOL> self . delegate = self . __delegate_class__ ( * args , ** kwargs ) <EOL> if kwargs . get ( '<STR_LIT>' , True ) : <EOL> self . synchro_connect ( ) <EOL> def synchro_connect ( self ) : <EOL> try : <EOL> self . synchronize ( self . delegate . open ) ( ) <EOL> except AutoReconnect as e : <EOL> raise ConnectionFailure ( str ( e ) ) <EOL> def start_request ( self ) : <EOL> raise NotImplementedError ( ) <EOL> in_request = end_request = start_request <EOL> @ property <EOL> def is_locked ( self ) : <EOL> result = self . admin . current_op ( ) <EOL> return bool ( result . get ( '<STR_LIT>' , None ) ) <EOL> def __enter__ ( self ) : <EOL> return self <EOL> def __exit__ ( self , * args ) : <EOL> self . delegate . disconnect ( ) <EOL> def __getattr__ ( self , name ) : <EOL> return Database ( self , name ) <EOL> __getitem__ = __getattr__ <EOL> class MongoClient ( MongoClientBase ) : <EOL> __delegate_class__ = motor . MotorClient <EOL> HOST = '<STR_LIT:localhost>' <EOL> PORT = <NUM_LIT> <EOL> def __init__ ( self , host = None , port = None , * args , ** kwargs ) : <EOL> host = host if host is not None else self . HOST <EOL> port = port if port is not None else self . PORT <EOL> super ( MongoClient , self ) . __init__ ( host , port , * args , ** kwargs ) <EOL> _MongoClient__member = SynchroProperty ( ) <EOL> _MongoClient__repl = SynchroProperty ( ) <EOL> _MongoClient__net_timeout = SynchroProperty ( ) <EOL> _MongoClient__conn_timeout = SynchroProperty ( ) <EOL> _MongoClient__wait_queue_timeout = SynchroProperty ( ) <EOL> _MongoClient__wait_queue_multiple = SynchroProperty ( ) <EOL> _MongoClient__socket_keepalive = SynchroProperty ( ) <EOL> _MongoClient__use_ssl = SynchroProperty ( ) <EOL> _MongoClient__ssl_keyfile = SynchroProperty ( ) <EOL> _MongoClient__ssl_certfile = SynchroProperty ( ) <EOL> _MongoClient__ssl_ca_certs = SynchroProperty ( ) <EOL> class MasterSlaveConnection ( object ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class MongoReplicaSetClient ( MongoClientBase ) : <EOL> __delegate_class__ = motor . MotorReplicaSetClient <EOL> get_default_database = WrapOutgoing ( ) <EOL> _MongoReplicaSetClient__writer = SynchroProperty ( ) <EOL> _MongoReplicaSetClient__rs_state = SynchroProperty ( ) <EOL> _MongoReplicaSetClient__schedule_refresh = SynchroProperty ( ) <EOL> _MongoReplicaSetClient__net_timeout = SynchroProperty ( ) <EOL> _MongoReplicaSetClient__conn_timeout = SynchroProperty ( ) <EOL> _MongoReplicaSetClient__wait_queue_timeout = SynchroProperty ( ) <EOL> _MongoReplicaSetClient__wait_queue_multiple = SynchroProperty ( ) <EOL> _MongoReplicaSetClient__socket_keepalive = SynchroProperty ( ) <EOL> _MongoReplicaSetClient__name = SynchroProperty ( ) <EOL> _MongoReplicaSetClient__use_ssl = SynchroProperty ( ) <EOL> _MongoReplicaSetClient__ssl_keyfile = SynchroProperty ( ) <EOL> _MongoReplicaSetClient__ssl_certfile = SynchroProperty ( ) <EOL> _MongoReplicaSetClient__ssl_ca_certs = SynchroProperty ( ) <EOL> class Database ( Synchro ) : <EOL> __delegate_class__ = motor . MotorDatabase <EOL> def __init__ ( self , client , name ) : <EOL> assert isinstance ( client , ( MongoClient , MongoReplicaSetClient ) ) , ( <EOL> "<STR_LIT>" <EOL> % repr ( client ) ) <EOL> self . connection = client <EOL> self . delegate = client . delegate [ name ] <EOL> assert isinstance ( self . delegate , motor . MotorDatabase ) , ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % repr ( self . delegate ) ) <EOL> def add_son_manipulator ( self , manipulator ) : <EOL> if isinstance ( manipulator , son_manipulator . AutoReference ) : <EOL> db = manipulator . database <EOL> if isinstance ( db , Database ) : <EOL> manipulator . database = db . delegate . delegate <EOL> self . delegate . add_son_manipulator ( manipulator ) <EOL> def __getattr__ ( self , name ) : <EOL> return Collection ( self , name ) <EOL> __getitem__ = __getattr__ <EOL> class Collection ( Synchro ) : <EOL> __delegate_class__ = motor . MotorCollection <EOL> find = WrapOutgoing ( ) <EOL> initialize_unordered_bulk_op = WrapOutgoing ( ) <EOL> initialize_ordered_bulk_op = WrapOutgoing ( ) <EOL> def __init__ ( self , database , name ) : <EOL> if not isinstance ( database , Database ) : <EOL> raise TypeError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % repr ( database ) ) <EOL> self . database = database <EOL> self . delegate = database . delegate [ name ] <EOL> if not isinstance ( self . delegate , motor . MotorCollection ) : <EOL> raise TypeError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % repr ( self . delegate ) ) <EOL> def __getattr__ ( self , name ) : <EOL> return Collection ( self . database , self . name + '<STR_LIT:.>' + name ) <EOL> __getitem__ = __getattr__ <EOL> class Cursor ( Synchro ) : <EOL> __delegate_class__ = motor . motor_tornado . MotorCursor <EOL> rewind = WrapOutgoing ( ) <EOL> clone = WrapOutgoing ( ) <EOL> close = Sync ( '<STR_LIT>' , False ) <EOL> def __init__ ( self , motor_cursor ) : <EOL> self . delegate = motor_cursor <EOL> def __iter__ ( self ) : <EOL> return self <EOL> @ wrap_synchro <EOL> def __copy__ ( self ) : <EOL> return self . delegate . __copy__ ( ) <EOL> @ wrap_synchro <EOL> def __deepcopy__ ( self , memo ) : <EOL> return self . delegate . __deepcopy__ ( memo ) <EOL> def next ( self ) : <EOL> cursor = self . delegate <EOL> if cursor . _buffer_size ( ) : <EOL> return cursor . next_object ( ) <EOL> elif cursor . alive : <EOL> self . synchronize ( cursor . _refresh ) ( ) <EOL> if cursor . _buffer_size ( ) : <EOL> return cursor . next_object ( ) <EOL> raise StopIteration <EOL> def __getitem__ ( self , index ) : <EOL> if isinstance ( index , slice ) : <EOL> return Cursor ( self . delegate [ index ] ) <EOL> else : <EOL> to_list = self . synchronize ( self . delegate [ index ] . to_list ) <EOL> return to_list ( length = <NUM_LIT> ) [ <NUM_LIT:0> ] <EOL> @ property <EOL> @ wrap_synchro <EOL> def collection ( self ) : <EOL> return self . delegate . collection <EOL> def __enter__ ( self ) : <EOL> return self <EOL> def __exit__ ( self , exc_type , exc_val , exc_tb ) : <EOL> self . close ( ) <EOL> return False <EOL> @ property <EOL> def _Cursor__slave_okay ( self ) : <EOL> pymongo_cursor = self . delegate . delegate <EOL> pref = pymongo_cursor . _Cursor__read_preference <EOL> return ( <EOL> pymongo_cursor . _Cursor__slave_okay <EOL> or pref != ReadPreference . PRIMARY ) <EOL> _Cursor__id = SynchroProperty ( ) <EOL> _Cursor__query_options = SynchroProperty ( ) <EOL> _Cursor__query_spec = SynchroProperty ( ) <EOL> _Cursor__retrieved = SynchroProperty ( ) <EOL> _Cursor__skip = SynchroProperty ( ) <EOL> _Cursor__limit = SynchroProperty ( ) <EOL> _Cursor__timeout = SynchroProperty ( ) <EOL> _Cursor__snapshot = SynchroProperty ( ) <EOL> _Cursor__tailable = SynchroProperty ( ) <EOL> _Cursor__as_class = SynchroProperty ( ) <EOL> _Cursor__await_data = SynchroProperty ( ) <EOL> _Cursor__partial = SynchroProperty ( ) <EOL> _Cursor__manipulate = SynchroProperty ( ) <EOL> _Cursor__query_flags = SynchroProperty ( ) <EOL> _Cursor__connection_id = SynchroProperty ( ) <EOL> _Cursor__read_preference = SynchroProperty ( ) <EOL> _Cursor__tag_sets = SynchroProperty ( ) <EOL> _Cursor__fields = SynchroProperty ( ) <EOL> _Cursor__spec = SynchroProperty ( ) <EOL> _Cursor__hint = SynchroProperty ( ) <EOL> _Cursor__exhaust = SynchroProperty ( ) <EOL> _Cursor__compile_re = SynchroProperty ( ) <EOL> _Cursor__max_time_ms = SynchroProperty ( ) <EOL> _Cursor__comment = SynchroProperty ( ) <EOL> _Cursor__min = SynchroProperty ( ) <EOL> _Cursor__max = SynchroProperty ( ) <EOL> _Cursor__secondary_acceptable_latency_ms = SynchroProperty ( ) <EOL> class CommandCursor ( Cursor ) : <EOL> __delegate_class__ = motor . motor_tornado . MotorCommandCursor <EOL> class GridOutCursor ( Cursor ) : <EOL> __delegate_class__ = motor . motor_tornado . MotorGridOutCursor <EOL> def __init__ ( self , delegate ) : <EOL> if not isinstance ( delegate , motor . motor_tornado . MotorGridOutCursor ) : <EOL> raise TypeError ( <EOL> "<STR_LIT>" % delegate ) <EOL> self . delegate = delegate <EOL> def next ( self ) : <EOL> motor_grid_out = super ( GridOutCursor , self ) . next ( ) <EOL> if motor_grid_out : <EOL> return GridOut ( self . collection , delegate = motor_grid_out ) <EOL> _Cursor__secondary_acceptable_latency_ms = SynchroProperty ( ) <EOL> class CursorManager ( object ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class BulkOperationBuilder ( Synchro ) : <EOL> __delegate_class__ = motor . MotorBulkOperationBuilder <EOL> def __init__ ( self , motor_bob ) : <EOL> if not isinstance ( motor_bob , motor . MotorBulkOperationBuilder ) : <EOL> raise TypeError ( <EOL> "<STR_LIT>" % motor_bob ) <EOL> self . delegate = motor_bob <EOL> class GridFS ( Synchro ) : <EOL> __delegate_class__ = motor . MotorGridFS <EOL> def __init__ ( self , database , collection = '<STR_LIT>' , _connect = True ) : <EOL> if not isinstance ( database , Database ) : <EOL> raise TypeError ( <EOL> "<STR_LIT>" % repr ( database ) ) <EOL> self . delegate = motor . MotorGridFS ( database . delegate , collection ) <EOL> def put ( self , * args , ** kwargs ) : <EOL> return self . synchronize ( self . delegate . put ) ( * args , ** kwargs ) <EOL> def find ( self , * args , ** kwargs ) : <EOL> motor_method = self . delegate . find <EOL> unwrapping_method = wrap_synchro ( unwrap_synchro ( motor_method ) ) <EOL> return unwrapping_method ( * args , ** kwargs ) <EOL> class GridIn ( Synchro ) : <EOL> __delegate_class__ = motor . MotorGridIn <EOL> def __init__ ( self , collection , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> delegate = kwargs . pop ( '<STR_LIT>' , None ) <EOL> if delegate : <EOL> self . delegate = delegate <EOL> else : <EOL> if not isinstance ( collection , Collection ) : <EOL> raise TypeError ( <EOL> "<STR_LIT>" % repr ( collection ) ) <EOL> self . delegate = motor . MotorGridIn ( collection . delegate , ** kwargs ) <EOL> def __getattr__ ( self , item ) : <EOL> return getattr ( self . delegate , item ) <EOL> class GridOut ( Synchro ) : <EOL> __delegate_class__ = motor . MotorGridOut <EOL> def __init__ ( <EOL> self , root_collection , file_id = None , file_document = None , <EOL> _connect = True , delegate = None ) : <EOL> """<STR_LIT>""" <EOL> if delegate : <EOL> self . delegate = delegate <EOL> else : <EOL> if not isinstance ( root_collection , Collection ) : <EOL> raise TypeError ( <EOL> "<STR_LIT>" % repr ( root_collection ) ) <EOL> self . delegate = motor . MotorGridOut ( <EOL> root_collection . delegate , file_id , file_document ) <EOL> if _connect : <EOL> self . synchronize ( self . delegate . open ) ( ) <EOL> def __getattr__ ( self , item ) : <EOL> self . synchronize ( self . delegate . open ) ( ) <EOL> return getattr ( self . delegate , item ) <EOL> def __setattr__ ( self , key , value ) : <EOL> if key in ( <EOL> "<STR_LIT>" , "<STR_LIT:name>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) : <EOL> raise AttributeError ( ) <EOL> super ( GridOut , self ) . __setattr__ ( key , value ) <EOL> class TimeModule ( object ) : <EOL> """<STR_LIT>""" <EOL> def __getattr__ ( self , item ) : <EOL> def sleep ( seconds ) : <EOL> loop = IOLoop . current ( ) <EOL> loop . add_timeout ( time . time ( ) + seconds , loop . stop ) <EOL> loop . start ( ) <EOL> if item == '<STR_LIT>' : <EOL> return sleep <EOL> else : <EOL> return getattr ( time , item ) </s>
