mirror of
				https://github.com/qurator-spk/modstool.git
				synced 2025-11-04 03:14:14 +01:00 
			
		
		
		
	✨ Convert mods:relatedItem for types original and host
Fixes gh-21.
This commit is contained in:
		
							parent
							
								
									6d8ba871eb
								
							
						
					
					
						commit
						4e7b8ed642
					
				
					 2 changed files with 22 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -152,6 +152,14 @@ def mods_to_dict(mods, raise_errors=True):
 | 
			
		|||
                .has_attributes({'authority': 'iso15924', 'type': 'code'}) \
 | 
			
		||||
                .text_set()
 | 
			
		||||
        elif tag == '{http://www.loc.gov/mods/v3}relatedItem':
 | 
			
		||||
            tag_group = TagGroup(tag, group)
 | 
			
		||||
            for type_, grouped_group in sorted_groupby(tag_group.group, key=lambda g: g.attrib['type']):
 | 
			
		||||
                sub_tag = 'relatedItem-{}'.format(type_)
 | 
			
		||||
                grouped_group = list(grouped_group)
 | 
			
		||||
                if type_ in ["original", "host"]:
 | 
			
		||||
                    value[sub_tag] = TagGroup(sub_tag, grouped_group).is_singleton().descend(raise_errors)
 | 
			
		||||
                else:
 | 
			
		||||
                    # TODO type="series"
 | 
			
		||||
                    pass
 | 
			
		||||
        elif tag == '{http://www.loc.gov/mods/v3}name':
 | 
			
		||||
            for n, e in enumerate(group):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,3 @@
 | 
			
		|||
from tkinter import W
 | 
			
		||||
from lxml import etree as ET
 | 
			
		||||
import pytest
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -126,3 +125,16 @@ def test_originInfo_no_event_type():
 | 
			
		|||
 | 
			
		||||
    assert len(ws) == 1
 | 
			
		||||
    assert ws[0].message.args[0] == 'Filtered {http://www.loc.gov/mods/v3}originInfo element (has no eventType)'
 | 
			
		||||
 | 
			
		||||
def test_relatedItem():
 | 
			
		||||
    d = dict_fromstring("""
 | 
			
		||||
    <mods:mods xmlns:mods="http://www.loc.gov/mods/v3">
 | 
			
		||||
        <mods:relatedItem type="original">
 | 
			
		||||
            <mods:recordInfo>
 | 
			
		||||
                <mods:recordIdentifier source="gbv-ppn">PPN167755803</mods:recordIdentifier>
 | 
			
		||||
            </mods:recordInfo>
 | 
			
		||||
        </mods:relatedItem>
 | 
			
		||||
    </mods:mods>
 | 
			
		||||
    """)
 | 
			
		||||
 | 
			
		||||
    assert d['relatedItem-original_recordInfo_recordIdentifier'] == 'PPN167755803'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue