<s> from types import ModuleType <EOL> from . resource import Resource <EOL> class SelfWrapper ( ModuleType ) : <EOL> def __init__ ( self , self_module , baked_args = { } ) : <EOL> for attr in [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] : <EOL> setattr ( self , attr , getattr ( self_module , attr , None ) ) <EOL> self . __path__ = [ ] <EOL> self . self_module = self_module <EOL> self . env = globals ( ) <EOL> def __setattr__ ( self , name , value ) : <EOL> if hasattr ( self , "<STR_LIT>" ) : <EOL> self . env [ name ] = value <EOL> ModuleType . __setattr__ ( self , name , value ) <EOL> def __getattr__ ( self , name ) : <EOL> if name == "<STR_LIT>" : <EOL> raise AttributeError <EOL> if name not in self . env : <EOL> host , prefix = self . _parse_name ( name ) <EOL> self . env [ name ] = Resource ( ) <EOL> self . env [ name ] . config . host = host <EOL> self . env [ name ] . config . prefix = prefix <EOL> return self . env [ name ] <EOL> def _parse_name ( self , name ) : <EOL> parts = name . split ( '<STR_LIT>' ) <EOL> host = parts [ <NUM_LIT:0> ] . replace ( '<STR_LIT:_>' , '<STR_LIT:.>' ) <EOL> prefix = '<STR_LIT:/>' <EOL> if len ( parts ) > <NUM_LIT:1> : <EOL> prefix = '<STR_LIT:/>' + parts [ <NUM_LIT:1> ] . replace ( '<STR_LIT:_>' , '<STR_LIT:/>' ) + '<STR_LIT:/>' <EOL> return host , prefix </s>
