<s> """<STR_LIT>""" <EOL> import sys <EOL> import inspect <EOL> from Rpyc . NetProxy import NetProxy , _get_conn <EOL> from Rpyc . Lib import ( <EOL> orig_isinstance , <EOL> orig_issubclass , <EOL> orig_dir , <EOL> orig_getattr , <EOL> orig_reload , <EOL> orig_help , <EOL> orig_type ) <EOL> __all__ = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> def dir ( * obj ) : <EOL> """<STR_LIT>""" <EOL> if not obj : <EOL> return sorted ( inspect . stack ( ) [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] . f_locals . keys ( ) ) <EOL> if not len ( obj ) == <NUM_LIT:1> : <EOL> raise TypeError ( "<STR_LIT>" % ( len ( obj ) , ) ) <EOL> obj = obj [ <NUM_LIT:0> ] <EOL> if orig_isinstance ( obj , NetProxy ) : <EOL> return _get_conn ( obj ) . modules . __builtin__ . dir ( obj ) <EOL> else : <EOL> return orig_dir ( obj ) <EOL> def getattr ( obj , name , * default ) : <EOL> """<STR_LIT>""" <EOL> if len ( default ) > <NUM_LIT:1> : <EOL> raise TypeError ( "<STR_LIT>" % ( <NUM_LIT:2> + len ( default ) , ) ) <EOL> if orig_isinstance ( obj , NetProxy ) : <EOL> try : <EOL> return obj . __getattr__ ( name ) <EOL> except AttributeError : <EOL> if not default : <EOL> raise <EOL> return default [ <NUM_LIT:0> ] <EOL> else : <EOL> return orig_getattr ( obj , name , * default ) <EOL> def hasattr ( obj , name ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> getattr ( obj , name ) <EOL> except AttributeError : <EOL> return False <EOL> else : <EOL> return True <EOL> def _get_fullname ( cls ) : <EOL> """<STR_LIT>""" <EOL> if orig_isinstance ( cls , NetProxy ) : <EOL> modules = _get_conn ( cls ) . modules . sys . modules <EOL> else : <EOL> modules = sys . modules <EOL> try : <EOL> filename = modules [ cls . __module__ ] . __file__ <EOL> except ( KeyError , AttributeError ) : <EOL> filename = cls . __module__ <EOL> return ( filename , cls . __name__ ) <EOL> def _recursive_issubclass ( cls , fullname ) : <EOL> for base in cls . __bases__ : <EOL> if _get_fullname ( base ) == fullname : <EOL> return True <EOL> if _recursive_issubclass ( base , fullname ) : <EOL> return True <EOL> return False <EOL> def _remote_issubclass ( cls , bases ) : <EOL> cls_fullname = _get_fullname ( cls ) <EOL> for base in bases : <EOL> base_fullname = _get_fullname ( base ) <EOL> if cls_fullname == base_fullname : <EOL> return True <EOL> if _recursive_issubclass ( cls , base_fullname ) : <EOL> return True <EOL> return False <EOL> def issubclass ( cls , bases ) : <EOL> """<STR_LIT>""" <EOL> if not orig_isinstance ( bases , tuple ) : <EOL> bases = ( bases , ) <EOL> if orig_isinstance ( cls , NetProxy ) : <EOL> return _remote_issubclass ( cls , bases ) <EOL> for base in bases : <EOL> if orig_isinstance ( base , NetProxy ) : <EOL> return _remote_issubclass ( cls , bases ) <EOL> return orig_issubclass ( cls , bases ) <EOL> def isinstance ( obj , bases ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> cls = obj . __getattr__ ( "<STR_LIT>" ) <EOL> except AttributeError : <EOL> try : <EOL> cls = obj . __class__ <EOL> except AttributeError : <EOL> cls = orig_type ( obj ) <EOL> return issubclass ( cls , bases ) <EOL> def reload ( module ) : <EOL> """<STR_LIT>""" <EOL> if orig_isinstance ( module , NetProxy ) : <EOL> return _get_conn ( module ) . modules . __builtin__ . reload ( module ) <EOL> else : <EOL> return orig_reload ( module ) <EOL> class _Helper ( object ) : <EOL> """<STR_LIT>""" <EOL> __repr__ = orig_help . __repr__ <EOL> def __call__ ( self , obj = None ) : <EOL> if orig_isinstance ( obj , NetProxy ) : <EOL> print "<STR_LIT>" % ( obj . __getattr__ ( "<STR_LIT>" ) . __name__ , ) <EOL> print <EOL> print "<STR_LIT>" <EOL> print obj . __getattr__ ( "<STR_LIT>" ) <EOL> print <EOL> print "<STR_LIT>" <EOL> print dir ( obj ) <EOL> else : <EOL> orig_help ( obj ) <EOL> help = _Helper ( ) </s>
