Exemplo n.º 1
0
def import_aliases(project, author, path):
    """ Set up a data pipeline and execute it. """
    with open(path, 'r') as fh:
        config = {'mapping': {
            'canonical': {'attribute': 'canonical'},
            'alias': {'attribute': 'alias'}
        }}
        name = os.path.basename(path)
        pipeline = pipelines.create(project, 'import',
            name, config, author)
        pipelines.start(pipeline)
        imports.import_aliases(pipeline, fh)
        pipelines.finish(pipeline)
Exemplo n.º 2
0
def import_aliases(project, author, path):
    """ Set up a data pipeline and execute it. """
    with open(path, 'r') as fh:
        config = {'mapping': {
            'canonical': {'attribute': 'canonical'},
            'alias': {'attribute': 'alias'}
        }}
        name = os.path.basename(path)
        pipeline = pipelines.create(project, 'import',
            name, config, author)
        pipelines.start(pipeline)
        imports.import_aliases(pipeline, fh)
        pipelines.finish(pipeline)
Exemplo n.º 3
0
Arquivo: imports.py Projeto: 01-/grano
def run_importer(pipeline_id):
    """ Perform a raw data import with a given mode. """

    pipeline = Pipeline.by_id(pipeline_id)
    pipelines.start(pipeline)

    mode = pipeline.config.get('mode')
    file_id = pipeline.config.get('file')
    file_ = File.by_id(file_id)
    if file_ is None:
        pipeline.log_error(pipeline, 'File object deleted: %s' % file_id)
    elif mode == 'aliases':
        import_aliases(pipeline, file_.fh)
    else:
        import_objects(pipeline, file_.fh)

    pipelines.finish(pipeline)
Exemplo n.º 4
0
def run_importer(pipeline_id):
    """ Perform a raw data import with a given mode. """

    pipeline = Pipeline.by_id(pipeline_id)
    pipelines.start(pipeline)

    mode = pipeline.config.get('mode')
    file_id = pipeline.config.get('file')
    file_ = File.by_id(file_id)
    if file_ is None:
        pipeline.log_error(pipeline, 'File object deleted: %s' % file_id)
    elif mode == 'aliases':
        import_aliases(pipeline, file_.fh)
    else:
        import_objects(pipeline, file_.fh)

    pipelines.finish(pipeline)