-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pre-Release Data Preparation Tool 3.5.0 (GND4C-Testing).
- Loading branch information
1 parent
9726dcc
commit dff6936
Showing
4 changed files
with
130 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
modules/provider_specific/.provider_script_sets/0c59f30406904f9c9a563a66f53b3d5f.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<provider_script_set><provider id="GND4C-NDS" range="global"><set id="0c59f30406904f9c9a563a66f53b3d5f"><name>GND4C-NDS-Format in MarcXML umwandeln</name><description></description><modules><module><module_provider>common</module_provider><module_name>maintenance_function.py</module_name><module_config>{'maintenance_type': 'mapping_definition'}</module_config></module><module><module_provider>GND4C</module_provider><module_name>split_marcxml_records_from_gnd4c_connector.py</module_name><module_config/></module></modules></set></provider></provider_script_set> | ||
<provider_script_set><provider id="GND4C-NDS" range="global"><set id="0c59f30406904f9c9a563a66f53b3d5f"><name>GND4C-NDS-Format in MarcXML umwandeln</name><description></description><modules><module><module_provider>common</module_provider><module_name>maintenance_function.py</module_name><module_config>{'maintenance_type': 'mapping_definition'}</module_config></module><module><module_provider>GND4C</module_provider><module_name>set_authentication_code_gnd3.py</module_name><module_config/></module><module><module_provider>GND4C</module_provider><module_name>set_general_note_labw.py</module_name><module_config/></module><module><module_provider>GND4C</module_provider><module_name>set_other_classification_number_from_config.py</module_name><module_config/></module><module><module_provider>GND4C</module_provider><module_name>set_source_data_found_from_config.py</module_name><module_config/></module><module><module_provider>GND4C</module_provider><module_name>set_teilbestandskennzeichen_d.py</module_name><module_config/></module><module><module_provider>GND4C</module_provider><module_name>sort_marcxml_fields.py</module_name><module_config/></module></modules></set></provider></provider_script_set> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from lxml import etree | ||
from loguru import logger | ||
|
||
|
||
def get_sort_key_from_tag(element): | ||
if "tag" in element.attrib: | ||
return element.attrib["tag"] | ||
else: | ||
return "00000000" | ||
|
||
def get_sort_key_from_code(element): | ||
if "code" in element.attrib: | ||
code_value = element.attrib["code"] | ||
if code_value.isnumeric(): | ||
# Subfields deren Code einen Buchstaben enthält, voranstellen. | ||
code_value = "zzzzzzzz{}".format(code_value) | ||
return code_value | ||
else: | ||
return "00000000" | ||
|
||
|
||
def parse_xml_content(xml_findbuch_in, input_type, input_file): | ||
"""control-, data- und subfields sortieren""" | ||
record_elements = xml_findbuch_in.findall("//{http://www.loc.gov/MARC21/slim}record") | ||
for record_element in record_elements: | ||
# controlfields und datafields sortieren | ||
record_element[:] = sorted(record_element, key=get_sort_key_from_tag) | ||
|
||
datafield_elements = record_element.findall("{http://www.loc.gov/MARC21/slim}datafield") | ||
for datafield_element in datafield_elements: | ||
# subfields sortieren | ||
datafield_element[:] = sorted(datafield_element, key=get_sort_key_from_code) | ||
|
||
return xml_findbuch_in |
Oops, something went wrong.