From d4df742e29a2f150246dfba3667ae5d6e09c6ff7 Mon Sep 17 00:00:00 2001 From: Micha Moskovic Date: Thu, 28 Sep 2023 09:03:40 +0200 Subject: [PATCH] Fix script to add MSNET ids to papers --- scripts/msnet_add_id/script.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/msnet_add_id/script.py b/scripts/msnet_add_id/script.py index 64cff0e..fb6540d 100644 --- a/scripts/msnet_add_id/script.py +++ b/scripts/msnet_add_id/script.py @@ -2,8 +2,8 @@ from inspirehep.curation.search_check_do import SearchCheckDo -URL = "https://cernbox.cern...msnet_add_id.txt" -MSNET_IDS = requests.get(URL) +URL = "https://cernbox.cern.ch/remote.php/dav/public-files/DgV3O0I8D8haXMZ/msnet_add_id.json" +MSNET_IDS = requests.get(URL).json() ELEMENT = "external_system_identifiers" @@ -15,12 +15,10 @@ class AddMsnetIds(SearchCheckDo): @staticmethod def check(record, logger, state): - if record.get_value("control_number") not in MSNET_IDS: - return True - for schema in record.get_value(f"{ELEMENT}.schema", []): - if schema == "MSNET": - return True - return False + return record["control_number"] in MSNET_IDS and not any( + id_["schema"] == "MSNET" + for id_ in record.get("external_system_identifiers", []) + ) @staticmethod def do(record, logger, state):