<s> """<STR_LIT>""" <EOL> import logging <EOL> import inspect <EOL> import re <EOL> from os . path import samefile <EOL> from . . import parameters <EOL> _pmodule_run_queue = None <EOL> _pmodule_run_set = None <EOL> _pmodule_lookup = None <EOL> def resetAndInitialize ( ) : <EOL> global _pmodule_lookup <EOL> global _pmodule_run_queue <EOL> global _pmodule_run_set <EOL> _pmodule_lookup = { } <EOL> _pmodule_run_queue = [ ] <EOL> _pmodule_run_set = set ( ) <EOL> def addToRunQueue ( module_name ) : <EOL> global _pmodule_run_queue <EOL> global _pmodule_run_set <EOL> if type ( module_name ) is not str : <EOL> raise TypeError ( "<STR_LIT>" % str ( type ( m ) ) ) <EOL> n = module_name . lower ( ) <EOL> if n not in _pmodule_run_set : <EOL> _pmodule_run_queue . append ( n ) <EOL> _pmodule_run_set . add ( n ) <EOL> def getCurrentRunQueue ( ) : <EOL> global _pmodule_run_queue <EOL> return [ s for s in _pmodule_run_queue ] <EOL> class PModulePreset ( object ) : <EOL> def __init__ ( self , name ) : <EOL> self . name = name <EOL> def __call__ ( self , p ) : <EOL> addToRunQueue ( self . name ) <EOL> def pmodule ( c ) : <EOL> global _pmodule_lookup <EOL> name = c . _name = c . __name__ . lower ( ) <EOL> assert type ( name ) is str <EOL> ret = _pmodule_lookup . setdefault ( name , c ) <EOL> if not ret is c : <EOL> if ( inspect . getsourcefile ( ret ) == inspect . getsourcefile ( c ) <EOL> or inspect . getfile ( ret ) == inspect . getfile ( c ) ) : <EOL> return c <EOL> raise NameError ( "<STR_LIT>" <EOL> % ( name , inspect . getfile ( ret ) , inspect . getfile ( c ) ) ) <EOL> c . log = logging . getLogger ( c . _name ) <EOL> parameters . processPModule ( c ) <EOL> parameters . registerPreset ( "<STR_LIT>" + name , PModulePreset ( name ) , <EOL> description = "<STR_LIT>" % c . __name__ ) <EOL> logging . getLogger ( "<STR_LIT>" ) . debug ( "<STR_LIT>" % c . __name__ ) <EOL> c . _is_pmodule = True <EOL> return c <EOL> def getPModuleClass ( name ) : <EOL> global _pmodule_lookup <EOL> try : <EOL> return _pmodule_lookup [ name ] <EOL> except KeyError : <EOL> raise NameError ( "<STR_LIT>" % name ) <EOL> def isPModule ( name ) : <EOL> global _pmodule_lookup <EOL> return name in _pmodule_lookup <EOL> def finalize ( ) : <EOL> pass </s>
