Example #1
0
def list_projects():
    """Query the Refine server and list projects by ID: name."""
    projects = refine.Refine(refine.RefineServer()).list_projects().items()

    def date_to_epoch(json_dt):
        """Convert a JSON date time into seconds-since-epoch."""
        return time.mktime(time.strptime(json_dt, '%Y-%m-%dT%H:%M:%SZ'))
    projects.sort(key=lambda v: date_to_epoch(v[1]['modified']), reverse=True)
    for project_id, project_info in projects:
        print('{0:>14}: {1}'.format(project_id, project_info['name']))
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)