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
| class PluginLoader: | |
| def load(self, directory): | |
| ret = [] | |
| for plugin in directory.children: | |
| plugin_file = plugin.children.find(name=plugin.name) | |
| plugin_class = plugin_file.classes[plugin.name] | |
| ret.append(plugin_class) |
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 imp | |
| import inspect | |
| import os | |
| import tempfile | |
| content = 'def func_name(a, b, c): pass' | |
| # generate tmp file containing py code to load | |
| # http://docs.python.org/library/tempfile.html#tempfile.mktemp | |
| temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.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 inspect | |
| import imp | |
| import os | |
| import tempfile | |
| class File: | |
| def __init__(self, path=None): | |
| self.classes = {} |
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 inspect | |
| import imp | |
| import os | |
| import tempfile | |
| from node import TreeNode | |
| class File(TreeNode): | |
| def __init__(self, path=None): | |
| super(File, self).__init__() |
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
| from file import PluginDirectory | |
| from interpreter import Interpreter | |
| from plugin_loader import PluginLoader | |
| class Application: | |
| def run(self): | |
| plugin_loader = PluginLoader() | |
| plugin_directory = PluginDirectory() | |
| commands = plugin_loader.load(plugin_directory) |
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 inspect | |
| import imp | |
| import os | |
| import tempfile | |
| from node import TreeNode | |
| class File(TreeNode): | |
| def __init__(self, path=None): | |
| super(File, self).__init__() |
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 inspect | |
| import imp | |
| import os | |
| from node import TreeNode | |
| class File(TreeNode): | |
| def __init__(self, path=None): | |
| super(File, self).__init__() |
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
| class PluginLoader: | |
| def load(self, directory): | |
| ret = [] | |
| for plugin in directory.children: | |
| plugin_file = plugin.find(name=plugin.name, type='py') | |
| plugin_class = plugin_file.classes[plugin.name] | |
| ret.append(plugin_class) |
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.path | |
| import inspect | |
| import imp | |
| import os | |
| from node import TreeNode | |
| class File(TreeNode): | |
| def __init__(self, path=None, name=None): | |
| super(File, self).__init__() |
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
| class PluginLoader: | |
| def load(self, directory): | |
| ret = [] | |
| for plugin in directory.children: | |
| plugin_file = plugin.find(name=plugin.name, type='py') | |
| plugin_class = plugin_file.classes[plugin.name] | |
| if not hasattr(plugin_class, 'matches'): |