예제 #1
0
def load_plugins(prefix, path, black_list, white_list):
    """Try to discover all pyexcel-io plugins"""
    scan_plugins(
        prefix,
        path,
        black_list,
        white_list  # constants.DEFAULT_PLUGIN_NAME,
    )
예제 #2
0
def test_load_plugins_import_error(mocked_load_me_later, pkgutil_iter_modules,
                                   pkgutil_get_importer):
    sample_toc = set(['test_non_existent_module'])
    pkgutil_get_importer.return_value.toc = sample_toc
    pkgutil_iter_modules.return_value = [('not used', 'pyexcel_xls', False)]
    from lml.loader import scan_plugins
    scan_plugins('test_', '.', ['pyexcel_io'])
    assert mocked_load_me_later.called is False
예제 #3
0
def test_load_plugins_import_error(mocked_load_me_later, pkgutil_iter_modules,
                                   pkgutil_get_importer):
    sample_toc = set(["test_non_existent_module"])
    pkgutil_get_importer.return_value.toc = sample_toc
    pkgutil_iter_modules.return_value = [("not used", "pyexcel_xls", False)]
    from lml.loader import scan_plugins

    scan_plugins("test_", ".", ["pyexcel_io"])
    assert mocked_load_me_later.called is False
예제 #4
0
def test_load_plugins_without_black_list(mocked_load_me_later,
                                         pkgutil_iter_modules,
                                         pkgutil_get_importer):
    sample_toc = set()
    pkgutil_get_importer.return_value.toc = sample_toc
    pkgutil_iter_modules.return_value = []
    from lml.loader import scan_plugins
    scan_plugins('pyexcel_', '.')
    assert mocked_load_me_later.called is False
예제 #5
0
def test_load_plugins_without_any_plugins(mocked_load_me_later,
                                          pkgutil_iter_modules,
                                          pkgutil_get_importer):
    sample_toc = set()
    pkgutil_get_importer.return_value.toc = sample_toc
    pkgutil_iter_modules.return_value = []
    from lml.loader import scan_plugins

    scan_plugins("pyexcel_", ".", ["pyexcel_io"])
    assert mocked_load_me_later.called is False
예제 #6
0
def test_load_plugins(pkgutil_iter_modules, pkgutil_get_importer):
    test_module_name = 'pyexcel_test'
    sample_toc = set(['pyexcel_io'])
    pkgutil_get_importer.return_value.toc = sample_toc
    pkgutil_iter_modules.return_value = [('not used', test_module_name, True)]
    from lml.loader import scan_plugins
    scan_plugins('pyexcel_', '.', ['pyexcel_io'])
    from lml.plugin import CACHED_PLUGIN_INFO
    info = CACHED_PLUGIN_INFO['test_io'][0]
    eq_(info.plugin_type, 'test_io')
    eq_(info.absolute_import_path, 'pyexcel_test.x')
예제 #7
0
def test_load_plugins(pkgutil_iter_modules, pkgutil_get_importer):
    test_module_name = "pyexcel_test"
    sample_toc = set(["pyexcel_io"])
    pkgutil_get_importer.return_value.toc = sample_toc
    pkgutil_iter_modules.return_value = [("not used", test_module_name, True)]
    from lml.loader import scan_plugins

    scan_plugins("pyexcel_", ".", ["pyexcel_io"])
    from lml.plugin import CACHED_PLUGIN_INFO

    info = CACHED_PLUGIN_INFO["test_io"][0]
    eq_(info.plugin_type, "test_io")
    eq_(info.absolute_import_path, "pyexcel_test.x")
예제 #8
0
파일: main.py 프로젝트: antherkiv/lml
def main():
    if len(sys.argv) < 2:
        sys.exit(-1)

    cuisine_manager = CuisineManager()
    scan_plugins("robotchef_", 'robotchef', white_list=BUILTINS)

    food_name = sys.argv[1]
    try:
        knowledged_chef = cuisine_manager.get_a_plugin(food_name)
        knowledged_chef.make(food=food_name)
    except NoChefException:
        print("I do not know how to cook " + food_name)
예제 #9
0
def test_load_plugins_without_pyinstaller(pkgutil_iter_modules,
                                          pkgutil_get_importer):
    test_module_name = "pyexcel_test"
    sample_toc = set()
    pkgutil_get_importer.return_value.toc = sample_toc
    # mock iter modules
    pkgutil_iter_modules.return_value = [("not used", test_module_name, True)]
    from lml.loader import scan_plugins

    scan_plugins("pyexcel_", ".", ["pyexcel_io"])
    from lml.plugin import CACHED_PLUGIN_INFO

    info = CACHED_PLUGIN_INFO["test_io"][0]
    assert info.plugin_type == "test_io"
    assert info.absolute_import_path == "pyexcel_test.x"
    def get_a_extension(self, name):
        if len(self.js_extensions) == 0:
            self.get_all_extensions()
        for __extension__ in self.js_extensions:
            if __extension__.registry[REGISTRY_JS_FOLDER] == name:
                return __extension__

        return None


EXTENSION_MANAGER = JsExtensionManager()
# Load js & map file index into a dictionary.
scan_plugins(
    THIRD_PARTY_PLUGIN_PREFIX,
    "pyecharts",  # <- useful for pyinstaller only
    white_list=OFFICIAL_PLUGINS,
)


def read_a_map_registry(registry_json):
    with codecs.open(registry_json, "r", "utf-8") as f:
        content = f.read()
        return json.loads(content)


def _validate_registry(registry):
    __registry_keys__ = [
        REGISTRY_JS_FOLDER,
        REGISTRY_FILE_MAP,
        REGISTRY_GITHUB_URL,
예제 #11
0
파일: __init__.py 프로젝트: ayan-b/lml
from lml.loader import scan_plugins
from robotchef_api.plugin import CuisineManager, NoChefException  # noqa: F401

BUILTINS = ["robotchef_api.robot_cuisine"]

scan_plugins("robotchef_", __path__, white_list=BUILTINS)  # noqa: F821
cuisine_manager = CuisineManager()
예제 #12
0
파일: __init__.py 프로젝트: nisarg4/mysite
    pyexcel.internal
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Pyexcel internals that subjected to change

    :copyright: (c) 2015-2017 by Onni Software Ltd.
    :license: New BSD License
"""
from lml.loader import scan_plugins
from pyexcel.internal.plugins import PARSER, RENDERER  # noqa
from pyexcel.internal.source_plugin import SOURCE  # noqa
from pyexcel.internal.generators import SheetStream, BookStream  # noqa

BLACK_LIST = [
    "pyexcel_io",
    "pyexcel_webio",
    "pyexcel_xlsx",
    "pyexcel_xls",
    "pyexcel_ods3",
    "pyexcel_ods",
    "pyexcel_odsr",
    "pyexcel_xlsxw",
]
WHITE_LIST = [
    "pyexcel.plugins.parsers",
    "pyexcel.plugins.renderers",
    "pyexcel.plugins.sources",
]

scan_plugins("pyexcel_", "pyexcel", BLACK_LIST, WHITE_LIST)
예제 #13
0
def init_plugins_instance():
    scan_plugins("irain_web_plugin", "irain_web_plugin")
    return dict(task=task())
예제 #14
0
파일: __init__.py 프로젝트: antherkiv/lml
from lml.loader import scan_plugins
from robotchef_api.plugin import CuisineManager, NoChefException  # flake8: noqa

BUILTINS = ['robotchef_api.robot_cuisine']

scan_plugins("robotchef_", __path__, white_list=BUILTINS)
cuisine_manager = CuisineManager()
예제 #15
0
    def get_a_extension(self, name):
        if len(self.js_extensions) == 0:
            self.get_all_extensions()
        for __extension__ in self.js_extensions:
            if __extension__.registry[REGISTRY_JS_FOLDER] == name:
                return __extension__

        return None


EXTENSION_MANAGER = JsExtensionManager()
# Load js & map file index into a dictionary.
scan_plugins(
    THIRD_PARTY_PLUGIN_PREFIX,
    "pyecharts",  # <- useful for pyinstaller only
    white_list=OFFICIAL_PLUGINS,
)


def read_a_map_registry(registry_json):
    with codecs.open(registry_json, "r", "utf-8") as f:
        content = f.read()
        return json.loads(content)


def _validate_registry(registry):
    __registry_keys__ = [
        REGISTRY_JS_FOLDER,
        REGISTRY_FILE_MAP,
        REGISTRY_GITHUB_URL,
예제 #16
0
파일: engine.py 프로젝트: SerekKiri/moban
        super(EngineFactory,
              self).__init__(constants.TEMPLATE_ENGINE_EXTENSION)

    def get_engine(self, template_type):
        return self.load_me_now(template_type)

    def all_types(self):
        return list(self.registry.keys())

    def raise_exception(self, key):
        raise exceptions.NoThirdPartyEngine(key)


ENGINES = EngineFactory()

scan_plugins("moban_", "moban", None, BUILTIN_EXENSIONS)


@PluginInfo(constants.TEMPLATE_ENGINE_EXTENSION,
            tags=["jinja2", "jinja", "jj2", "j2"])
class Engine(object):
    def __init__(self, template_dirs, context_dirs):
        verify_the_existence_of_directories(template_dirs)
        template_loader = FileSystemLoader(template_dirs)
        self.jj2_environment = Environment(
            loader=template_loader,
            keep_trailing_newline=True,
            trim_blocks=True,
            lstrip_blocks=True,
        )
        for filter_name, filter_function in _FILTERS.get_all():
예제 #17
0
"""
    pyexcel.internal
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Pyexcel internals that subjected to change

    :copyright: (c) 2015-2017 by Onni Software Ltd.
    :license: New BSD License
"""
from lml.loader import scan_plugins
from pyexcel.internal.plugins import PARSER, RENDERER  # noqa
from pyexcel.internal.source_plugin import SOURCE  # noqa
from pyexcel.internal.generators import SheetStream, BookStream  # noqa


BLACK_LIST = ['pyexcel_io', 'pyexcel_webio',
              'pyexcel_xlsx', 'pyexcel_xls',
              'pyexcel_ods3', 'pyexcel_ods',
              'pyexcel_odsr', 'pyexcel_xlsxw']
WHITE_LIST = [
    'pyexcel.plugins.parsers',
    'pyexcel.plugins.renderers',
    'pyexcel.plugins.sources',
]


scan_plugins('pyexcel_', 'pyexcel', BLACK_LIST, WHITE_LIST)