<s> import sys <EOL> import types <EOL> import fnmatch <EOL> import threading <EOL> def universalImport ( * names ) : <EOL> """<STR_LIT>""" <EOL> f = sys . _getframe ( <NUM_LIT:1> ) <EOL> for name in names : <EOL> try : <EOL> ret = __import__ ( name , f . f_globals ) <EOL> except ImportError : <EOL> continue <EOL> else : <EOL> if '<STR_LIT:.>' in name : <EOL> parts = name . split ( '<STR_LIT:.>' ) [ <NUM_LIT:1> : ] <EOL> while parts : <EOL> ret = getattr ( ret , parts [ <NUM_LIT:0> ] ) <EOL> del parts [ <NUM_LIT:0> ] <EOL> return ret <EOL> raise ImportError ( '<STR_LIT:U+002C>' . join ( names ) ) <EOL> def changeFunctionName ( f , name , doc = None ) : <EOL> if doc is None : <EOL> doc = f . __doc__ <EOL> if hasattr ( f , '<STR_LIT>' ) : <EOL> closure = f . __closure__ <EOL> else : <EOL> closure = f . func_closure <EOL> newf = types . FunctionType ( f . __code__ , f . __globals__ , name , <EOL> f . __defaults__ , closure ) <EOL> newf . __doc__ = doc <EOL> return newf <EOL> class Object ( object ) : <EOL> def __ne__ ( self , other ) : <EOL> return not self == other <EOL> class MetaSynchronized ( type ) : <EOL> METHODS = '<STR_LIT>' <EOL> LOCK = '<STR_LIT>' <EOL> def __new__ ( cls , name , bases , dict ) : <EOL> sync = set ( ) <EOL> for base in bases : <EOL> if hasattr ( base , MetaSynchronized . METHODS ) : <EOL> sync . update ( getattr ( base , MetaSynchronized . METHODS ) ) <EOL> if MetaSynchronized . METHODS in dict : <EOL> sync . update ( dict [ MetaSynchronized . METHODS ] ) <EOL> if sync : <EOL> def synchronized ( f ) : <EOL> def g ( self , * args , ** kwargs ) : <EOL> lock = getattr ( self , MetaSynchronized . LOCK ) <EOL> lock . acquire ( ) <EOL> try : <EOL> f ( self , * args , ** kwargs ) <EOL> finally : <EOL> lock . release ( ) <EOL> return changeFunctionName ( g , f . __name__ , f . __doc__ ) <EOL> for attr in sync : <EOL> if attr in dict : <EOL> dict [ attr ] = synchronized ( dict [ attr ] ) <EOL> original__init__ = dict . get ( '<STR_LIT>' ) <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> if not hasattr ( self , MetaSynchronized . LOCK ) : <EOL> setattr ( self , MetaSynchronized . LOCK , threading . RLock ( ) ) <EOL> if original__init__ : <EOL> original__init__ ( self , * args , ** kwargs ) <EOL> else : <EOL> super ( newclass , self ) . __init__ ( * args , ** kwargs ) <EOL> dict [ '<STR_LIT>' ] = __init__ <EOL> newclass = super ( MetaSynchronized , cls ) . __new__ ( cls , name , bases , dict ) <EOL> return newclass <EOL> Synchronized = MetaSynchronized ( '<STR_LIT>' , ( ) , { } ) <EOL> def glob2re ( g ) : <EOL> return fnmatch . translate ( g ) [ : - <NUM_LIT:7> ] <EOL> _debug_software_name = '<STR_LIT>' <EOL> _debug_software_version = None <EOL> def collect_extra_debug_data ( ) : <EOL> """<STR_LIT>""" <EOL> data = '<STR_LIT>' <EOL> try : <EOL> tb = sys . exc_info ( ) [ <NUM_LIT:2> ] <EOL> stack = [ ] <EOL> while tb : <EOL> stack . append ( tb . tb_frame ) <EOL> tb = tb . tb_next <EOL> finally : <EOL> del tb <EOL> if _debug_software_version : <EOL> data += '<STR_LIT>' % ( _debug_software_name , _debug_software_version ) <EOL> else : <EOL> data += '<STR_LIT>' % _debug_software_name <EOL> data += '<STR_LIT>' <EOL> for frame in stack : <EOL> data += '<STR_LIT>' <EOL> data += ( '<STR_LIT>' % ( frame . f_code . co_name , <EOL> frame . f_code . co_filename , <EOL> frame . f_lineno ) ) <EOL> frame_locals = frame . f_locals <EOL> for inspected in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> if inspected in frame_locals : <EOL> if hasattr ( frame_locals [ inspected ] , '<STR_LIT>' ) and frame_locals [ inspected ] . __dict__ : <EOL> for ( key , value ) in frame_locals [ inspected ] . __dict__ . items ( ) : <EOL> frame_locals [ '<STR_LIT>' % ( inspected , key ) ] = value <EOL> for key , value in frame_locals . items ( ) : <EOL> if key == '<STR_LIT>' : <EOL> continue <EOL> data += ( '<STR_LIT>' % key ) <EOL> try : <EOL> data += repr ( value ) + '<STR_LIT:\n>' <EOL> except : <EOL> data += '<STR_LIT>' <EOL> data += '<STR_LIT:\n>' <EOL> data += '<STR_LIT>' <EOL> data += '<STR_LIT>' <EOL> data += '<STR_LIT>' <EOL> data += '<STR_LIT:\n>' <EOL> return data </s>
