コード例 #1
0
mapfile = inputfile.name + ".mapping.xlsx"
if os.path.exists(mapfile):
    previous_output = tablib.import_book(open(mapfile,"rb"))
    previous = yaml.load(previous_output.yaml)
else:
    previous = []    

mapping = XlsxMapping(omeka_client, previous)


id_mapping = []
for d in data:
    collection_name =  d['title']
    logger.info("Processing potential collection: %s", collection_name)
    iterations = mapping.upload_collection_multiple_times(collection_name)
    collection_id = omeka_client.getCollectionId(collection_name, create=args['create_collections'], public=args["public"])
    if collection_id <> None:
        #Work out which fields can be automagically mapped
        if not collection_name in mapping.collection_field_mapping:
            logger.info("No mapping data for this collection. Attempting to make one")
            mapping.collection_field_mapping[collection_name] = {}
            
      
        
        def map_element(key, element_id, set_name):
            mapping.collection_field_mapping[collection_name][key] = element_id
            mapping.supplied_element_names.append({"Collection": collection_name,
                            "Column": key,
                            "Omeka Element Set": set_name,
                            "Omeka Element": key,
                            "Linked": "",
コード例 #2
0
omeka_client = OmekaClient(endpoint.encode("utf-8"), apikey)
file_stash = re.sub(":|/","_",endpoint) + ".json"

print file_stash;

if os.path.exists(file_stash):
    id_map = json.load(open(file_stash))
else:
    id_map = {}

dir = args['dir']

exif_id = omeka_client.getSetId("EXIF", create=True)
dc_id = omeka_client.getSetId("Dublin Core")
title_id = omeka_client.getElementId(dc_id, "Title")
collection_id = omeka_client.getCollectionId("Photos", create=True)
item_type_id = omeka_client.getItemTypeId("Still Image", create=True)
exif_fields = ["LensID", "FOV", "DOF", "Make", "Model", "FileName", "ExposureTime", "FNumber", "FocusDistance"]
for root, dirs, files in os.walk(dir):
    for file in files:
        ext = os.path.splitext(file)[1]
        if ext.lower() in extensions:
            file_path = os.path.join(root, file)
            pic_data = json.loads(subprocess.check_output(["exiftool", "-json", file_path]))[0]
            #TODO - upload the pics

            #TODO Create new fields for new metadata.
           
            element_texts = []
            
            for field in exif_fields:
コード例 #3
0
ファイル: xlsx2omeka.py プロジェクト: uws-eresearch/omekadd
mapfile = inputfile.name + ".mapping.xlsx"
if os.path.exists(mapfile):
    previous_output = tablib.import_book(open(mapfile,"rb"))
    previous = yaml.load(previous_output.yaml)
else:
    previous = []    

mapping = XlsxMapping(omeka_client, previous)


id_mapping = []
for d in data:
    collection_name =  d['title']
    logger.info("Processing potential collection: %s", collection_name)
    iterations = mapping.upload_collection_multiple_times(collection_name)
    collection_id = omeka_client.getCollectionId(collection_name, create=args['create_collections'])
    if collection_id <> None:
        #Work out which fields can be automagically mapped
        if not collection_name in mapping.collection_field_mapping:
            logger.info("No mapping data for this collection. Attempting to make one")
            mapping.collection_field_mapping[collection_name] = {}
            
      
        
        def map_element(key, element_id, set_name):
            mapping.collection_field_mapping[collection_name][key] = element_id
            mapping.supplied_element_names.append({"Collection": collection_name,
                            "Column": key,
                            "Omeka Element Set": set_name,
                            "Omeka Element": key,
                            "Linked": "",