def get_pm_ark(job, baseDirectory): metadata = parseMetadata(job, baseDirectory, {}) if not metadata: return '' ark = '' for entry, data in metadata.items(): for name, values in data.items(): if name == 'dcterms.identifier' and ark == '': ark = get_pm_ark_in_values(values) return ark
def get_pm_ark_and_aspace_uri(job, baseDirectory): metadata = parseMetadata(job, baseDirectory, {}) if not metadata: return '' ark = '' uri = '' title = '' do_uuid = '' for entry, data in metadata.items(): for name, values in data.items(): if name == 'dcterms.identifier' and ark == '': ark = get_pm_ark_in_values(values) if name == 'uhlib.aSpaceUri' and uri == '': uri = values[0] if name == 'dcterms.title' and title == '': title = values[0] if name == 'uhlib.doUuid' and do_uuid == '': do_uuid = values[0] return {'ark': ark, 'uri': uri, 'do_uuid': do_uuid, 'title': title}
sets=[("TYPE", "Directory"), ("LABEL", item)]) DMDIDS = createDMDIDSFromCSVParsedMetadataDirectories( itemdirectoryPath.replace(baseDirectoryPath, "", 1)) if DMDIDS: directoryDiv.set("DMDID", DMDIDS) createFileSec(itemdirectoryPath, directoryDiv) if __name__ == '__main__': sharedVariablesAcrossModules.collator = PyICU.Collator.createInstance( PyICU.Locale(opts.PyICULocale)) while False: #used to stall the mcp and stop the client for testing this module import time time.sleep(10) parseMetadata(baseDirectoryPath) if not baseDirectoryPath.endswith('/'): baseDirectoryPath += '/' structMap = etree.Element("structMap") structMap.set("TYPE", "physical") structMap.set("ID", "structMap_1") structMap.set("LABEL", "Archivematica default") structMapDiv = newChild(structMap, "div", sets=[("TYPE", "Directory"), ("LABEL", os.path.basename(baseDirectoryPath[:-1]))]) structMapDiv = newChild(structMapDiv, "div", sets=[("TYPE", "Directory"), ("LABEL", "objects")])
parser.add_option("-a", "--amdSec", action="store_true", dest="amdSec", default=False) (opts, args) = parser.parse_args() baseDirectoryPath = opts.baseDirectoryPath XMLFile = opts.xmlFile includeAmdSec = opts.amdSec baseDirectoryPathString = "%%%s%%" % (opts.baseDirectoryPathString) fileGroupIdentifier = opts.fileGroupIdentifier fileGroupType = opts.fileGroupType includeAmdSec = opts.amdSec while False: #used to stall the mcp and stop the client for testing this module import time time.sleep(10) CSV_METADATA = parseMetadata(baseDirectoryPath) if not baseDirectoryPath.endswith('/'): baseDirectoryPath += '/' structMap = etree.Element(ns.metsBNS + "structMap", TYPE='physical', ID='structMap_1', LABEL="Archivematica default") structMapDiv = etree.SubElement(structMap, ns.metsBNS + 'div', TYPE="Directory", LABEL=os.path.basename(baseDirectoryPath.rstrip('/'))) structMapDivObjects = createFileSec(os.path.join(baseDirectoryPath, "objects"), structMapDiv, baseDirectoryPath, baseDirectoryPathString, fileGroupIdentifier, fileGroupType, includeAmdSec) el = create_object_metadata(structMapDivObjects, baseDirectoryPath) if el: amdSecs.append(el) createFileSec(os.path.join(baseDirectoryPath, "metadata"), structMapDiv, baseDirectoryPath, baseDirectoryPathString, fileGroupIdentifier, fileGroupType, includeAmdSec) fileSec = etree.Element(ns.metsBNS + "fileSec")
itemdirectoryPath = os.path.join(directoryPath, item) directoryDiv = newChild(structMapDiv, "div", sets=[("TYPE","Directory"), ("LABEL",item)]) DMDIDS = createDMDIDSFromCSVParsedMetadataDirectories(itemdirectoryPath.replace(baseDirectoryPath, "", 1)) if DMDIDS: directoryDiv.set("DMDID", DMDIDS) createFileSec(itemdirectoryPath, directoryDiv) if __name__ == '__main__': sharedVariablesAcrossModules.collator = PyICU.Collator.createInstance(PyICU.Locale(opts.PyICULocale)) while False: #used to stall the mcp and stop the client for testing this module import time time.sleep(10) parseMetadata(baseDirectoryPath) if not baseDirectoryPath.endswith('/'): baseDirectoryPath += '/' structMap = etree.Element("structMap") structMap.set("TYPE", "physical") structMap.set("ID", "structMap_1") structMap.set("LABEL", "Archivematica default") structMapDiv = newChild(structMap, "div", sets=[("TYPE","Directory"), ("LABEL",os.path.basename(baseDirectoryPath[:-1]))]) structMapDiv = newChild(structMapDiv, "div", sets=[("TYPE","Directory"), ("LABEL","objects") ]) createFileSec(os.path.join(baseDirectoryPath, "objects"), structMapDiv) fileSec = etree.Element( "fileSec") for group in globalFileGrpsUses: #globalFileGrps.itervalues(): grp = globalFileGrps[group]
includeAmdSec = opts.amdSec # If reingesting, do not create a new METS, just modify existing one if 'REIN' in SIP_TYPE: print('Updating METS during reingest') # fileGroupIdentifier is SIPUUID, baseDirectoryPath is SIP dir, root = archivematicaCreateMETSReingest.update_mets( baseDirectoryPath, fileGroupIdentifier, ) tree = etree.ElementTree(root) write_mets(tree, XMLFile) sys.exit(0) # End reingest CSV_METADATA = parseMetadata(baseDirectoryPath) baseDirectoryPath = os.path.join(baseDirectoryPath, '') objectsDirectoryPath = os.path.join(baseDirectoryPath, 'objects') # Delete empty directories, see #8427 for root, dirs, files in os.walk(baseDirectoryPath, topdown=False): try: os.rmdir(root) print("Deleted empty directory", root) except OSError: pass structMap = etree.Element(ns.metsBNS + "structMap", TYPE='physical', ID='structMap_1', LABEL="Archivematica default") structMapDiv = etree.SubElement(structMap, ns.metsBNS + 'div', TYPE="Directory", LABEL=os.path.basename(baseDirectoryPath.rstrip('/'))) structMapDivObjects = createFileSec(objectsDirectoryPath, structMapDiv, baseDirectoryPath, baseDirectoryPathString, fileGroupIdentifier, fileGroupType, includeAmdSec)