This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main(): | |
#main loop | |
#.... | |
if irc_line is a message: | |
sawMessage(channel, user, message) | |
#.... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pluginExists(self, pluginName): | |
if os.path.exists(pluginName.replace(".", os.sep)+".py"): | |
f = __import__("plugins."+pluginName.split(".")[0], fromlist=[pluginName.split(".")[1]]) | |
try: | |
getattr(f, pluginName.split(".")[1]) | |
del f | |
del sys.modules["plugins."+pluginName.split(".")[0]] | |
return True | |
except AttributeError: | |
del f |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Test Summary Report | |
------------------- | |
t/00bootstrap.t (Wstat: 512 Tests: 2 Failed: 2) | |
Failed tests: 1-2 | |
Non-zero exit status: 2 | |
t/connect.t (Wstat: 512 Tests: 0 Failed: 0) | |
Non-zero exit status: 2 | |
Parse errors: No plan found in TAP output | |
Files=2, Tests=2, 1 wallclock secs ( 0.08 usr 0.03 sys + 0.30 cusr 0.03 csys = 0.44 CPU) | |
Result: FAIL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import exocet | |
import inspect | |
PluginList = { } | |
modules = [m for m in exocet.getModule("plugins").iterModules()] | |
for module in modules: | |
m = module.load() | |
for name, obj in inspect.getmembers(m): | |
if inspect.isclass(obj): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import exocet | |
import inspect | |
_ClassList = { } | |
def refresh(moduleName=None): | |
if moduleName is None: | |
_ClassList.clear() | |
modules = [m for m in exocet.getModule("plugins").iterModules()] | |
for module in modules: | |
m = module.load() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
code_environment = load_some_code(string_or_file_or_code_object); | |
classObject = code_environment.SomeClass(args); | |
.... do stuff with classObject | |
code_environment = load_some_code(string); | |
classObject = code_environment.SomeClass(args); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, inspect | |
pList = { } | |
mList = { } | |
def plugin(cls): | |
try: | |
mList[inspect.stack()[1][1].split(os.sep)[1]].append(cls.__name__) | |
except KeyError: | |
mList[inspect.stack()[1][1].split(os.sep)[1]] = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, inspect | |
pList = { } | |
mList = defaultdict(list) | |
def plugin(cls): | |
#Using inspect, figure out what file is calling this function (using @plugin) | |
clsFile = inspect.stack()[1][1] | |
#Split the path, because it will be in the form "plugins" + os.sep + "*.py" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, inspect, collections | |
pList = { } | |
mList = collections.defaultdict(list) | |
class NoSuchPluginError(Exception): pass | |
def plugin(cls): | |
#Using inspect, figure out what file is calling this function (using @plugin) | |
clsFile = inspect.stack()[1][1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys, new | |
modules = { } | |
def loadModule(moduleName, locals_dict={}): | |
""" | |
Imports a module without using the built-in import functions. | |
Parameters: | |
moduleName - The name of the module, same as if you were using __import__ or import |