<s> class Processing ( object ) : <EOL> def __init__ ( self , name , process , ** kwargs ) : <EOL> self . name = name <EOL> self . process = process <EOL> self . config_args = kwargs <EOL> self . dispatch_args = [ y [ : - <NUM_LIT:8> ] for y in self . config_args if y . endswith ( "<STR_LIT>" ) ] <EOL> def dispatch ( self , features = None , params = None ) : <EOL> if features == None : <EOL> features = [ ] <EOL> if params == None : <EOL> params = { } <EOL> kwargs = { } <EOL> for arg in self . dispatch_args : <EOL> if self . config_args . has_key ( "<STR_LIT>" % arg ) : <EOL> kwargs [ arg ] = self . config_args [ '<STR_LIT>' % arg ] <EOL> for arg in self . dispatch_args : <EOL> if self . config_args . has_key ( "<STR_LIT>" % arg ) and self . config_args [ '<STR_LIT>' % arg ] . lower ( ) in [ '<STR_LIT:yes>' , '<STR_LIT:y>' , '<STR_LIT:true>' , '<STR_LIT:1>' ] : <EOL> continue <EOL> key = "<STR_LIT>" % ( self . name , arg ) <EOL> if params . has_key ( key ) : <EOL> kwargs [ arg ] = params [ key ] <EOL> return self . process ( features , ** kwargs ) <EOL> def loadFromSection ( config , section ) : <EOL> mod = config . get ( section , "<STR_LIT>" ) <EOL> cls = config . get ( section , "<STR_LIT:class>" ) <EOL> mod_name = mod . split ( "<STR_LIT:.>" ) [ - <NUM_LIT:1> ] <EOL> module = __import__ ( mod , globals ( ) , locals ( ) , mod_name ) <EOL> action = getattr ( module , cls ) <EOL> objargs = { } <EOL> for opt in config . options ( section ) : <EOL> if opt not in [ "<STR_LIT>" , "<STR_LIT:class>" ] : <EOL> objargs [ opt ] = config . get ( section , opt ) <EOL> name = section [ <NUM_LIT:8> : ] <EOL> p = Processing ( name , action ( ) , ** objargs ) <EOL> return p </s>
