Skip to content

Commit

Permalink
Fixes issue in check_integrity script
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Krieter committed Jul 31, 2024
1 parent 855316b commit d16bc47
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scripts/check_integrity.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
title_regex = re.compile(r"^\{.*\}$", re.DOTALL)
pages_regex = re.compile(r"^[a-zA-Z0-9,.:()]+(--[a-zA-Z0-9,.:()]+)?$", re.DOTALL)
author_regex = re.compile(r"([^,]+),[^,]+(\s+and\s+([^,]+),[^,]+)*", re.DOTALL)
doi_regex = re.compile(r"^http(s)?://.*", re.DOTALL)
url_doi_regex = re.compile(r"^http(s)?://.*", re.DOTALL)
doi_regex = re.compile(r"^[a-zA-Z0-9-_.:;(){}<>]+/[a-zA-Z0-9-_.:;(){}<>/]+$", re.DOTALL)

## Different types of fields. Required fields must be present. Wanted fields should be present. Optional can be present be don't need to be.
## Which fields are which type is dependent on the entry type. This is defined in the field_types.yaml configuration file.
Expand Down Expand Up @@ -117,12 +118,15 @@ def check_pages(entry):


## Checks that the DOI of an entry are formated correctly
def check_pages(entry):
def check_doi(entry):
if ('doi' in entry):
org = entry['doi']
if is_set('doi'):
if (doi_regex.match(org)):
if (url_doi_regex.match(org)):
add_problem(entry, 'doi_is_an_url', org)
else:
if (not doi_regex.match(org)):
add_problem(entry, 'incorrect_doi', org)


## Checks that the names of authors of an entry follow the syntax "last name, first name"
Expand Down Expand Up @@ -244,6 +248,7 @@ def check_key(entry):
check_author(entry)
check_key(entry)
check_pages(entry)
check_doi(entry)

new_strings = {}
for entry in bib_database.entries:
Expand Down

0 comments on commit d16bc47

Please sign in to comment.