Example #1
0
def main():
    """Main."""
    options, args = PARSER.parse_args()

    if options.host:
        refine.REFINE_HOST = options.host
    if options.port:
        refine.REFINE_PORT = options.port

    if not options.list and len(args) != 1:
        PARSER.print_usage()
    if options.list:
        list_projects()
    if args:
        project = refine.RefineProject(args[0])
        if options.apply:
            response = project.apply_operations(options.apply)
            if response != 'ok':
                print >>sys.stderr, 'Failed to apply %s: %s' % (options.apply,
                                                                response)
        if options.export:
            export_project(project, options)

        return project
Example #2
0
def get_operations(project_id,rep_name):
    # get the json
    res = refine.RefineProject(refine.RefineServer(), project_id).get_operations()
    with open(f'load_recipe/{rep_name}.json', 'w') as fout:
        json.dump(res , fout,indent=4)
Example #3
0
def load_recipe(project_id, rep_path):
    rep = refine.RefineProject(refine.RefineServer(),
                               project_id).get_operations()
    with open(f'../OpenRefine_recipe/{rep_path}.json', 'w') as fout:
        json.dump(rep, fout, indent=4)
Example #4
0
def apply_operations(project_id, file_path):
    # apply operations: apply the json file
    return refine.RefineProject(refine.RefineServer(),
                                project_id).apply_operations(file_path)