From 3158806a8ef8d4c4dc9a151aa8666feb9f0fda87 Mon Sep 17 00:00:00 2001 From: Heinz-Alexander Fuetterer Date: Fri, 22 Sep 2023 14:29:13 +0200 Subject: [PATCH] fix: make re-strings raw strings to fix DeprecationWarnings --- fuji_server/harvester/metadata_harvester.py | 8 ++++---- fuji_server/helper/identifier_helper.py | 2 +- fuji_server/helper/metadata_collector_xml.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fuji_server/harvester/metadata_harvester.py b/fuji_server/harvester/metadata_harvester.py index ea930054..fff9626b 100644 --- a/fuji_server/harvester/metadata_harvester.py +++ b/fuji_server/harvester/metadata_harvester.py @@ -476,13 +476,13 @@ def parse_signposting_http_link_format(self, signposting_link_format_text): for link_prop in parsed_link[1:]: link_prop = str(link_prop).strip() if link_prop.startswith('anchor'): - anchor_match = re.search('anchor\s*=\s*\"?([^,;"]+)\"?', link_prop) + anchor_match = re.search(r'anchor\s*=\s*\"?([^,;"]+)\"?', link_prop) if link_prop.startswith('rel'): - rel_match = re.search('rel\s*=\s*\"?([^,;"]+)\"?', link_prop) + rel_match = re.search(r'rel\s*=\s*\"?([^,;"]+)\"?', link_prop) elif link_prop.startswith('type'): - type_match = re.search('type\s*=\s*\"?([^,;"]+)\"?', link_prop) + type_match = re.search(r'type\s*=\s*\"?([^,;"]+)\"?', link_prop) elif link_prop.startswith('formats'): - formats_match = re.search('formats\s*=\s*\"?([^,;"]+)\"?', link_prop) + formats_match = re.search(r'formats\s*=\s*\"?([^,;"]+)\"?', link_prop) if type_match: found_type = type_match[1] if rel_match: diff --git a/fuji_server/helper/identifier_helper.py b/fuji_server/helper/identifier_helper.py index d95bc561..b0647b61 100644 --- a/fuji_server/helper/identifier_helper.py +++ b/fuji_server/helper/identifier_helper.py @@ -121,7 +121,7 @@ def __init__(self, idstring, logger = None): #workaround to identify arks properly: self.identifier = self.identifier.replace('/ark:' , '/ark:/' ) self.identifier = self.identifier.replace('/ark://', '/ark:/') - generic_identifiers_org_pattern = '^([a-z0-9\._]+):(.+)' + generic_identifiers_org_pattern = r'^([a-z0-9\._]+):(.+)' if self.is_uuid(): self.identifier_schemes = ['uuid'] diff --git a/fuji_server/helper/metadata_collector_xml.py b/fuji_server/helper/metadata_collector_xml.py index 60b84a9b..a3bbfe5f 100644 --- a/fuji_server/helper/metadata_collector_xml.py +++ b/fuji_server/helper/metadata_collector_xml.py @@ -314,7 +314,7 @@ def get_mapped_xml_metadata(self, tree, mapping): res[prop] = propcontent[0].get('tree').text else: res[prop] = lxml.etree.tostring(propcontent[0].get('tree'), method='text', encoding='unicode') - res[prop] = re.sub('\s+', ' ', res[prop]) + res[prop] = re.sub(r'\s+', ' ', res[prop]) res[prop] = res[prop].strip() else: for propelem in propcontent: @@ -324,7 +324,7 @@ def get_mapped_xml_metadata(self, tree, mapping): res[prop].append(propelem.get('tree').text) else: resprop = lxml.etree.tostring(propelem.get('tree'), method='text', encoding='unicode') - resprop = re.sub('\s+', ' ', resprop) + resprop = re.sub(r'\s+', ' ', resprop) resprop = resprop.strip() res[prop].append(resprop)