<s> import os <EOL> import sys <EOL> import imp <EOL> import pickle <EOL> import traceback <EOL> import md5 <EOL> from collections import namedtuple <EOL> Result = namedtuple ( '<STR_LIT>' , [ '<STR_LIT:type>' , '<STR_LIT:content>' ] ) <EOL> choco = None <EOL> module = None <EOL> modules = [ ] <EOL> def init_module ( cc , ep ) : <EOL> global choco , module <EOL> choco = cc <EOL> module = ep <EOL> def dispatch ( room , message ) : <EOL> choco . dispatch ( room , message , True ) <EOL> def module_loader ( home , config ) : <EOL> for fn in os . listdir ( os . path . join ( home , '<STR_LIT>' ) ) : <EOL> name = os . path . basename ( fn ) [ : - <NUM_LIT:3> ] <EOL> if name in config . EXCLUDED_MODULES : continue <EOL> if fn . endswith ( '<STR_LIT>' ) and not fn . startswith ( '<STR_LIT:_>' ) : <EOL> fn = os . path . join ( os . path . dirname ( os . path . realpath ( __file__ ) ) , fn ) <EOL> try : modules . append ( imp . load_source ( name , fn ) ) <EOL> except Exception , e : <EOL> traceback . print_exc ( ) <EOL> print >> sys . stderr , "<STR_LIT>" % ( name , e ) <EOL> sys . exit ( <NUM_LIT:1> ) </s>
