Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if len(sys.argv) == 3:
input_directory, outputfilename = sys.argv[1:]
writer = pymarc.XMLWriter(open(outputfilename, "wb"))
for root, _, files in os.walk(input_directory):
for filename in files:
if not filename.endswith(".xml"):
continue
inputfilepath = os.path.join(root, filename)
for oldrecord in xmlstream(inputfilepath, "record"):
oldrecord = BytesIO(oldrecord)
oldrecord = pymarc.marcxml.parse_xml_to_array(oldrecord)
oldrecord = oldrecord[0]
marcrecord = marcx.Record.from_record(oldrecord)
marcrecord.force_utf8 = True
marcrecord.strict = False
try:
marcrecord["245"]["a"]
except:
continue
# Identifikator
f001 = marcrecord["001"].data
marcrecord.remove_fields("001")
marcrecord.add("001", data="183-" + f001)