Skip to content
Snippets Groups Projects
Commit d2d35f90 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

FIX: several fixes

parent 4c423631
Branches
Tags
2 merge requests!91Release 0.3,!65MAINT: make DictXYElements XYElements
Pipeline #30404 passed
......@@ -115,13 +115,14 @@ def test_single_insertion(clear_database, usemodel, crawler, ident):
if res[i].parents[0].name == "PyTestInfo":
del res[i]
filename = rfp("..", "..", "unittests", "records.xml")
with open(filename, "w") as f:
xml = res.to_xml()
# Remove noscript and transaction benchmark:
for tag in ("noscript", "TransactionBenchmark"):
if xml.find(tag) is not None:
xml.remove(xml.find(tag))
f.write(db.common.utils.xml2str(xml))
# TODO can we remove this? why should we overwrite the current xml
# with open(filename, "w") as f:
# xml = res.to_xml()
# # Remove noscript and transaction benchmark:
# for tag in ("noscript", "TransactionBenchmark"):
# if xml.find(tag) is not None:
# xml.remove(xml.find(tag))
# f.write(db.common.utils.xml2str(xml))
assert len(ins) == 18
assert len(ups) == 0
......
......@@ -211,7 +211,7 @@ Data:
subtree:
related_to_doi_element:
type: TextElement
match: "(?P<related_to_doi>).*"
match_value: "(?P<related_to_doi>).*"
records:
Dataset:
related_to_dois: +$related_to_doi
......
......@@ -766,6 +766,15 @@ class TextElementConverter(_AbstractScalarValueElementConverter):
"accept_float": True,
}
def __init__(self, definition, *args, **kwargs):
if "match" in definition:
raise ValueError("""
The 'match' key will in future be used to match a potential name of a TextElement. Please use
the 'match_value' key to match the value of the TextElement and 'match_name' for matching the name.
""")
super().__init__(definition, *args, **kwargs)
class DictTextElementConverter(TextElementConverter):
def __init__(self, *args, **kwargs):
......
......@@ -42,14 +42,14 @@ Data: # name of the converter
# how to make match case insensitive?
subtree:
description:
type: DictTextElement
type: TextElement
match_value: (?P<description>.*)
match_name: description
records:
Measurement:
description: $description
responsible_single:
type: DictTextElement
type: TextElement
match_name: responsible
match_value: &person_regexp ((?P<first_name>.+) )?(?P<last_name>.+)
records: &responsible_records
......@@ -68,7 +68,7 @@ Data: # name of the converter
subtree:
Person:
type: TextElement
match: *person_regexp
match_value: *person_regexp
records: *responsible_records
ExperimentalData: # name of the converter
......
......@@ -55,14 +55,14 @@ Data: # name of the converter
subtree:
description:
type: DictTextElement
type: TextElement
match_value: (?P<description>.*)
match_name: description
records:
Measurement:
description: $description
responsible_single:
type: DictTextElement
type: TextElement
match_name: responsible
match_value: &person_regexp ((?P<first_name>.+) )?(?P<last_name>.+)
records: &responsible_records
......@@ -76,12 +76,12 @@ Data: # name of the converter
# "responsible" belonging to Measurement.
responsible_list:
type: DictListElement
type: ListElement
match_name: responsible
subtree:
Person:
type: TextElement
match: *person_regexp
match_value: *person_regexp
records: *responsible_records
# sources_list:
......
......@@ -56,14 +56,14 @@ Data: # name of the converter
subtree:
description:
type: DictTextElement
type: TextElement
match_value: (?P<description>.*)
match_name: description
records:
Measurement:
description: $description
responsible_single:
type: DictTextElement
type: TextElement
match_name: responsible
match_value: &person_regexp ((?P<first_name>.+) )?(?P<last_name>.+)
records: &responsible_records
......@@ -77,12 +77,12 @@ Data: # name of the converter
# "responsible" belonging to Measurement.
responsible_list:
type: DictListElement
type: ListElement
match_name: responsible
subtree:
Person:
type: TextElement
match: *person_regexp
match_value: *person_regexp
records: *responsible_records
# sources_list:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment