Skip to content

Commit

Permalink
workflows: avoid populating countries with cern cooperation agreement (
Browse files Browse the repository at this point in the history
  • Loading branch information
drjova authored Jun 30, 2023
1 parent 0dff51a commit 5fce3f6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion scoap3/modules/workflows/workflows/articles_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from __future__ import absolute_import, division, print_function

import re
import json
import logging
from StringIO import StringIO
Expand Down Expand Up @@ -127,11 +128,22 @@ def add_nations(obj, eng):
if "authors" not in obj.data:
__halt_and_notify("No authors for article.", eng)

pattern_for_cern_cooperation_agreement = re.compile(
r'cooperation agreement with cern', re.IGNORECASE)

for author_index, author in enumerate(obj.data["authors"]):
if "affiliations" not in author:
__halt_and_notify("No affiliations for author: %s." % author, eng)

for affiliation_index, affiliation in enumerate(author["affiliations"]):
# hack to avoid populating country <https://github.com/cern-sis/issues-scoap3/issues/168>
match_pattern = pattern_for_cern_cooperation_agreement.search(affiliation['value'])
if match_pattern:
logger.warning(
"The affiliation contains cooperation agreement: '%s'"
% affiliation['value']
)
continue

obj.data["authors"][author_index]["affiliations"][affiliation_index][
"country"
] = find_country(affiliation["value"])
Expand Down

0 comments on commit 5fce3f6

Please sign in to comment.