Browse Source

Allowed for missing DC

main
astanley 2 years ago
parent
commit
b3e390aa2a
  1. 11
      FoxmlWorker.py
  2. 4
      ImportServerUtilities.py

11
FoxmlWorker.py

@ -30,10 +30,14 @@ class FWorker:
def get_pid(self): def get_pid(self):
return self.root.attrib['PID'] return self.root.attrib['PID']
# gets state # Gets state
def get_state(self): def get_state(self):
return self.properties['state'] return self.properties['state']
# Gets label
def get_label(self):
return self.properties['label']
# Gets all properties. # Gets all properties.
def get_properties(self): def get_properties(self):
values = {} values = {}
@ -80,6 +84,9 @@ class FWorker:
dc_nodes = self.root.findall(f'.//foxml:datastream[@ID="DC"]/foxml:datastreamVersion/foxml:xmlContent', dc_nodes = self.root.findall(f'.//foxml:datastream[@ID="DC"]/foxml:datastreamVersion/foxml:xmlContent',
namespaces=self.namespaces) namespaces=self.namespaces)
dc_values = [] dc_values = []
if not dc_nodes:
print(f"{self.get_pid()}: No DC values found.")
return dc_values
dc_node = dc_nodes[-1] dc_node = dc_nodes[-1]
for child in dc_node.iter(): for child in dc_node.iter():
if child.text is not None: if child.text is not None:
@ -133,4 +140,4 @@ class FWorker:
if __name__ == '__main__': if __name__ == '__main__':
FW = FWorker('assets/sample_fox.xml') FW = FWorker('assets/sample_fox.xml')
print(FW.get_rels_ext_values())

4
ImportServerUtilities.py

@ -1,3 +1,5 @@
#!/usr/bin/env python3
# Utility class for functions to be run on the server # Utility class for functions to be run on the server
import csv import csv
import shutil import shutil
@ -119,7 +121,7 @@ class ImportServerUtilities:
continue continue
relations = fw.get_rels_ext_values() relations = fw.get_rels_ext_values()
row = {} row = {}
row['title'] = fw.get_dc_values()[0]['title'] row['title'] = fw.get_label()
row['pid'] = pid row['pid'] = pid
for relation, value in relations.items(): for relation, value in relations.items():
if relation in self.iu.rels_map: if relation in self.iu.rels_map:

Loading…
Cancel
Save