<s> import sys <EOL> import types <EOL> PY3 = sys . version_info [ <NUM_LIT:0> ] == <NUM_LIT:3> <EOL> def _import_module ( name ) : <EOL> """<STR_LIT>""" <EOL> __import__ ( name ) <EOL> return sys . modules [ name ] <EOL> class _LazyDescr ( object ) : <EOL> def __init__ ( self , name ) : <EOL> self . name = name <EOL> def __get__ ( self , obj , tp ) : <EOL> result = self . _resolve ( ) <EOL> setattr ( obj , self . name , result ) <EOL> delattr ( tp , self . name ) <EOL> return result <EOL> class MovedModule ( _LazyDescr ) : <EOL> def __init__ ( self , name , old , new = None ) : <EOL> super ( MovedModule , self ) . __init__ ( name ) <EOL> if PY3 : <EOL> if new is None : <EOL> new = name <EOL> self . mod = new <EOL> else : <EOL> self . mod = old <EOL> def _resolve ( self ) : <EOL> return _import_module ( self . mod ) <EOL> class MovedAttribute ( _LazyDescr ) : <EOL> def __init__ ( self , name , old_mod , new_mod , old_attr = None , new_attr = None ) : <EOL> super ( MovedAttribute , self ) . __init__ ( name ) <EOL> if PY3 : <EOL> if new_mod is None : <EOL> new_mod = name <EOL> self . mod = new_mod <EOL> if new_attr is None : <EOL> if old_attr is None : <EOL> new_attr = name <EOL> else : <EOL> new_attr = old_attr <EOL> self . attr = new_attr <EOL> else : <EOL> self . mod = old_mod <EOL> if old_attr is None : <EOL> old_attr = name <EOL> self . attr = old_attr <EOL> def _resolve ( self ) : <EOL> module = _import_module ( self . mod ) <EOL> return getattr ( module , self . attr ) <EOL> class _MovedItems ( types . ModuleType ) : <EOL> """<STR_LIT>""" </s>
