From 116a26f072e8628cc4cfabb2e55c6661b6b94605 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 15 Apr 2020 21:35:48 -0700 Subject: consistently use raw string prefix for regex --- python/fatcat_tools/importers/common.py | 2 +- python/fatcat_tools/normal.py | 10 +++++----- python/fatcat_web/forms.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/python/fatcat_tools/importers/common.py b/python/fatcat_tools/importers/common.py index da611ecb..99c330a6 100644 --- a/python/fatcat_tools/importers/common.py +++ b/python/fatcat_tools/importers/common.py @@ -306,7 +306,7 @@ class EntityImporter: self._issnl_id_map = dict() self._orcid_id_map = dict() - self._orcid_regex = re.compile("^\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]$") + self._orcid_regex = re.compile(r"^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$") self._doi_id_map = dict() self._pmid_id_map = dict() diff --git a/python/fatcat_tools/normal.py b/python/fatcat_tools/normal.py index 7a2b5fd9..528a822e 100644 --- a/python/fatcat_tools/normal.py +++ b/python/fatcat_tools/normal.py @@ -6,7 +6,7 @@ free-form input, titles, etc. import re -DOI_REGEX = re.compile("^10.\d{3,6}/\S+$") +DOI_REGEX = re.compile(r"^10.\d{3,6}/\S+$") def clean_doi(raw): """ @@ -66,7 +66,7 @@ def test_clean_doi(): assert clean_doi("doi:10.1234/ asdf ") == None assert clean_doi("10.4149/gpb¬_2017042") == None # "logical negation" character -ARXIV_ID_REGEX = re.compile("^(\d{4}.\d{4,5}|[a-z\-]+(\.[A-Z]{2})?/\d{7})(v\d+)?$") +ARXIV_ID_REGEX = re.compile(r"^(\d{4}.\d{4,5}|[a-z\-]+(\.[A-Z]{2})?/\d{7})(v\d+)?$") def clean_arxiv_id(raw): """ @@ -175,7 +175,7 @@ def test_clean_sha256(): assert clean_sha256("6cc853f2ae75696b2e45f476c76b946b0fc2df7c52bb38287cb074aceb77bc7f") == "6cc853f2ae75696b2e45f476c76b946b0fc2df7c52bb38287cb074aceb77bc7f" assert clean_sha256("0fba3fba0e1937aa0297de3836b768b5dfb23d7b") == None -ISSN_REGEX = re.compile("^\d{4}-\d{3}[0-9X]$") +ISSN_REGEX = re.compile(r"^\d{4}-\d{3}[0-9X]$") def clean_issn(raw): if not raw: @@ -193,7 +193,7 @@ def test_clean_issn(): assert clean_issn("134-4567") == None assert clean_issn("123X-4567") == None -ISBN13_REGEX = re.compile("^97(?:8|9)-\d{1,5}-\d{1,7}-\d{1,6}-\d$") +ISBN13_REGEX = re.compile(r"^97(?:8|9)-\d{1,5}-\d{1,7}-\d{1,6}-\d$") def clean_isbn13(raw): if not raw: @@ -209,7 +209,7 @@ def test_clean_isbn13(): assert clean_isbn13("978-1-56619-909-4 ") == "978-1-56619-909-4" assert clean_isbn13("9781566199094") == None -ORCID_REGEX = re.compile("^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$") +ORCID_REGEX = re.compile(r"^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$") def clean_orcid(raw): if not raw: diff --git a/python/fatcat_web/forms.py b/python/fatcat_web/forms.py index dd322cff..377e35aa 100644 --- a/python/fatcat_web/forms.py +++ b/python/fatcat_web/forms.py @@ -91,7 +91,7 @@ class ReleaseEntityForm(EntityEditForm): [validators.Optional(True)]) #release_year doi = StringField('DOI', - [validators.Regexp('^10\..*\/.*', message="DOI must be valid"), + [validators.Regexp(r'^10\..*\/.*', message="DOI must be valid"), validators.Optional(True)]) wikidata_qid = StringField('Wikidata QID') isbn13 = StringField('ISBN-13') -- cgit v1.2.3