Fix f-strings for Python 3.5

pull/37/head
Benjamin Rosemann 4 years ago
parent 7b27b2834e
commit c02569b41e

@ -241,7 +241,7 @@ def get_textequiv_unicode(text_segment, nsmap) -> str:
return '' return ''
textequiv = get_first_textequiv(textequivs, segment_id) textequiv = get_first_textequiv(textequivs, segment_id)
return textequiv.find('./page:Unicode', namespaces=nsmap).text return textequiv.find('./page:Unicode', namespaces=nsmap).text or ''
def get_first_textequiv(textequivs, segment_id): def get_first_textequiv(textequivs, segment_id):

@ -95,12 +95,13 @@ def test_textequiv(attributes, expected_index, expected_log, caplog):
caplog.set_level(logging.INFO) caplog.set_level(logging.INFO)
xml = "<?xml version=\"1.0\"?>" xml = "<?xml version=\"1.0\"?>"
ns = "http://schema.primaresearch.org/PAGE/gts/pagecontent/2018-07-15" ns = "http://schema.primaresearch.org/PAGE/gts/pagecontent/2018-07-15"
text = [f"Text {i}" for i in range(len(attributes) + 1)] text = ["Text {0}".format(i) for i in range(len(attributes) + 1)]
equiv = [f"<TextEquiv {attr}><Unicode>{text[i]}</Unicode></TextEquiv>" equiv = ["<TextEquiv {0}><Unicode>{1}</Unicode></TextEquiv>".format(attr, text[i])
for i, attr in enumerate(attributes)] for i, attr in enumerate(attributes)]
textline = f"{xml}<TextLine id=\"l3\" xmlns=\"{ns}\">{''.join(equiv)}</TextLine>" textline = "{0}<TextLine id=\"l3\" xmlns=\"{1}\">{2}</TextLine>"
textline = textline.format(xml, ns, ''.join(equiv))
root = ET.fromstring(textline) root = ET.fromstring(textline)
result = ExtractedText.from_text_segment(root, result = ExtractedText.from_text_segment(root,

Loading…
Cancel
Save