def main(argv, otherArg=None): args = _parse_command_line_args(sys.argv) if not args[_SOURCE]: util.report_error("No input file specified.") filepath = args[_SOURCE][0] # The full module name as a string # FIXME: hardcoded to 0-index only importpath = args[_IMPORT_PATH] ext = util.parse_file_extension_from_filepath(filepath) if ext != constants.SCRIBBLE_FILE_EXTENSION: util.report_error("Bad file extension: " + ext) module_ = util.load_file_and_parse_module(filepath) # Returns an antlr3.tree.CommonTree with the module as the root # Section 4.2 -- module dependencies. Load all the modules that the target # module_ may depend on Initial Context is outside of the AST (no # parent/node) -- these fields are initialised on entering the AST from the # root module node context_ = Context(args[_IMPORT_PATH], args[_PAYLOAD_TYPE_PATH]) context_ = load_modules(context_, filepath, module_) # TODO: import members not supported yet # Next passes can do transformations on the raw AST # Insert implicit scopes in each protocol of each module_ context_ = _insert_scopes(context_) # Raw transformations finished; next record individual members (for # convenience -- currently only used by projection; ContextVisitor passes # use visibility) context_ = load_members(context_, filepath, module_) # Context built up to now is the base context. Subsequent ContextVisitor # passes each start from the base Context and build/manipulate the # pass-specific Context as appropriate # Section 4.2 -- well-formedness of primary module. Separately build the # visibility context_ for each dependency (it can be different for each) and # check the well-formedness conditions that must hold for each dependency # checks well-formedness conditions on each in-context_ module (these are # the loaded modules, which are the dependencies of the primary module) _check_wellformedness(context_) # Here the Context has only modules and members loaded, no # visibility built (Context was not retained from well-formedness checking). # The returned context_ holds all the projections context_ = _project_all(context_) # Check reachability at the local protocol level _check_reachability(context_) proto = args[_PROJECT_PROTOCOL] if proto is not None: localrole = args[_PROJECT_ROLE] dir = args[_PROJECT_DIR] #context_ = _project(context_, proto, localrole, dir) _output_projections_to_modules(context_, proto, localrole, dir)
def start_modules(self, event): self.modules = moduleloader.load_modules(self.ed) LoginEvent(self.name).post(self.ed)
# custom functionality and module imports import re import json import urllib2 import messageparser # configuration imports import ConfigParser from signal import SIGTERM #First up, load the rest of the bot specific modules import moduleloader CFG = moduleloader.load_config() MODULES = moduleloader.load_modules(CFG) # bot class class earlbot(sleekxmpp.ClientXMPP): """ A simple SleekXMPP bot that will parse a message according to a list of loaded custom modules. """ def __init__(self, jid, password, rooms, nick): sleekxmpp.ClientXMPP.__init__(self, jid, password) self.rooms = rooms self.nick = nick self.mute = False