Skip to content

Commit d9949c9

Browse files
committed
Add Thesis abstract special handling (DSpace <p> element).
1 parent 19c2901 commit d9949c9

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/compare_csv.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,20 @@ def string_compare_ignore_whitespace(str1, str2):
118118
return ret
119119

120120

121+
#
122+
def abstract_compare(str1, list2):
123+
"""
124+
Thesis abstract REST API result have <p></p> elements
125+
remove from comparison
126+
"""
127+
logging.debug("%s ---- %s", str1, list2)
128+
list2 = list2.replace("<p>", "").replace("</p>", "")
129+
list2 = utils.convert_string_list_representation_to_list(list2)
130+
logging.debug("%s ---- %s", str1, list2)
131+
132+
return True if not str1 and not list2 else str1 in list2
133+
134+
121135
# Scholaris removes trailing linebreaks
122136
def string_in_list_compare_ignore_whitespace(str1, list2):
123137
"""
@@ -501,7 +515,7 @@ def special_type_compare(row, key, value):
501515
"jupiter": "abstract",
502516
"dspace": "metadata.dc.description.abstract",
503517
},
504-
"comparison_function": string_compare,
518+
"comparison_function": abstract_compare,
505519
},
506520
"access_rights": {
507521
"columns": {"jupiter": "visibility", "dspace": "access_rights"},

src/tests/test_integration.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ def test_string_compare_ignore_whitespace():
5757
assert compare.string_compare_ignore_whitespace(float(), float()) is True
5858

5959

60+
def test_abstract_compare():
61+
"""
62+
Test abstract
63+
"""
64+
assert compare.abstract_compare("a", "['a']") is True
65+
assert compare.abstract_compare("a", "['<p>a</p>']") is True
66+
assert compare.abstract_compare("a. ", "['<p>a. </p>']") is True
67+
68+
6069
def test_string_in_list_compare_ignore_whitespace():
6170
"""
6271
Strip trailing and leading whitespace (e.g., description in Jupiter)

0 commit comments

Comments
 (0)