diff --git a/transmogrifier/sources/xml/marc.py b/transmogrifier/sources/xml/marc.py index d6cd72f..dfb72e7 100644 --- a/transmogrifier/sources/xml/marc.py +++ b/transmogrifier/sources/xml/marc.py @@ -731,7 +731,7 @@ def _get_language_names( language_name for language_code in list(dict.fromkeys(language_codes)) if ( - language_name := Marc.loc_crosswalk_code_to_name( + language_name := cls.loc_crosswalk_code_to_name( language_code, cls.language_code_crosswalk, cls.get_source_record_id(source_record), @@ -826,21 +826,9 @@ def get_locations(cls, source_record: Tag) -> list[timdex.Location] | None: "kind": "Hierarchical Place Name", }, ] - # get locations (place of publication) from control field 008/15-17 - if ( - fixed_location_code := cls._get_control_field(source_record)[15:18].strip() - ) and ( - location_name := Marc.loc_crosswalk_code_to_name( - code=fixed_location_code, - crosswalk=cls.country_code_crosswalk, - record_id=cls.get_source_record_id(source_record), - code_type="country", - ) - ): - locations.append( - timdex.Location(value=location_name, kind="Place of Publication") - ) + if place_of_publication := cls._get_location_publication(source_record): + locations.append(place_of_publication) # get locations from data fields for location_marc_field in location_marc_fields: @@ -866,6 +854,21 @@ def get_locations(cls, source_record: Tag) -> list[timdex.Location] | None: ) return locations or None + @classmethod + def _get_location_publication(cls, source_record: Tag) -> timdex.Location | None: + if ( + fixed_location_code := cls._get_control_field(source_record)[15:18].strip() + ) and ( + location_name := cls.loc_crosswalk_code_to_name( + code=fixed_location_code, + crosswalk=cls.country_code_crosswalk, + record_id=cls.get_source_record_id(source_record), + code_type="country", + ) + ): + return timdex.Location(value=location_name, kind="Place of Publication") + return None + @classmethod def get_notes(cls, source_record: Tag) -> list[timdex.Note] | None: notes = []