Ejemplo n.º 1
0
def run(pluginManager):
    """
    Called by the plugin manager.
    Asks the plugin manager for user input and
    configures the database generator to generate
    the desired database file.
    """
    import lauescript.database as db
    from lauescript.types.data import GENERATOR
    from lauescript.laueio.inout import FlexLoad
    from lauescript.laueio.loader import Loader
    from lauescript.core.core import apd_exit

    printer = pluginManager.setup()
    data = DATA()
    loader = Loader(printer)
    pluginManager.register_variable(loader, 'loader')
    pluginManager.register_variable(data, 'data')
    dabapath = '.'
    match = pluginManager.arg('match')
    if pluginManager.arg('generate'):
        printer('Generating new micro database.')
        data = GENERATOR([], True)
        path = pluginManager.arg('load')
        db.generate_micro_database(data, pluginManager.get_frequency_cutoff(), path=path,
                                   printer=printer, clustersize=int(pluginManager.arg('cluster')),
                                   frequency_scale=pluginManager.get_config_valueFloat('Database', 'frequency_scale'))
        apd_exit(0)
    data = pluginManager.get_variable()
    printer('Loading data.')
    filename = pluginManager.arg('load')
    printer('Setting ADP transfer mode to pattern matching.\n')
    loader = Loader(printer)
    pluginManager.register_variable(loader, 'loader')
    if filename:
        if '.apd' in filename:
            printer('APD-Script file found. Executing script.')
            from lauescript.scripting import Parser

            parser = Parser(filename, indent=5)
            printer.enter()
            parser()
            printer.exit()
            apd_exit()
        FlexLoad(data, loader, dabapath, pluginManager, filename, noTransfer=True)
        # data['exp'] = quickLoad(pluginManager, filename)
    else:
        FlexLoad(data, loader, dabapath, pluginManager, noTransfer=True)
        # data['exp'] = quickLoad(pluginManager, filename)
    printer('Loading successful.')
    printer.spacer()
    printer('\nUsing option {} to transfer ADPs.'.format(match))
    data.update(match=match)
Ejemplo n.º 2
0
def run(pluginManager):
    """
    Asks the plugin manager for user input and executes
    the APD-Toolkit's main functions.
    """
    from lauescript.laueio.inout import FlexLoad
    from lauescript.laueio.loader import Loader
    from lauescript.types.data import DATA
    from os.path import isfile

    printer = pluginManager.setup()
    data = DATA()
    loader = Loader(printer)
    pluginManager.register_variable(loader, 'loader')
    pluginManager.register_variable(data, 'data')
    planarityThreshold = float(pluginManager.arg('planarity'))
    # data.register_pluginManager(pluginManager)
    dabapath = pluginManager.get_databasepath()
    # print(pluginManager.arg('temp'))
    # print(pluginManager.arg('load'))

    filename = pluginManager.arg('load')
    if not isfile(filename):
        filename = None
        printer('No file specified. Searching for files in working directory.'
                '\nTo specify a file use \'load <filename>\'.\n')
    if filename:
        # if filename.endswith('.apd'):
        #     printer('APD-Script file found. Executing script.')
        #     from lauescript.core.scripting import Parser
        #
        #     parser = Parser(filename, indent=5, config=pluginManager)
        #     printer.enter()
        #     parser()
        #     printer.exit()
        #     exit()
        FlexLoad(data, loader, dabapath, pluginManager, filename, planarityThreshold=planarityThreshold)
    else:
        FlexLoad(data, loader, dabapath, pluginManager, planarityThreshold=planarityThreshold)
    printer('Loading successful.')
    data.update()