File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
scripts/fix-fermilab-urls Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ import requests
2+
3+ from inspirehep .curation .search_check_do import SearchCheckDo
4+
5+ FIXED_URLS = requests .get (
6+ "https://cernbox.cern.ch/remote.php/dav/public-files/"
7+ "FVgeaG5VAVx8B09/fermilab_fixed_urls.json"
8+ ).json ()
9+
10+
11+ class FixFermilabURLs (SearchCheckDo ):
12+ """Rewrite URLs to Fermilab PDFs that have moved."""
13+
14+ query = "urls.value:'ccd.fnal.gov'"
15+
16+ @staticmethod
17+ def check (record , logger , state ):
18+ for url in record .get_value ("urls.value" , []):
19+ if "ccd.fnal.gov" not in url :
20+ continue
21+ if url in FIXED_URLS :
22+ return True
23+ logger .warning ("URL not found in translation map" , url = url )
24+ return False
25+
26+ @staticmethod
27+ def do (record , logger , state ):
28+ for url in record ["urls" ]:
29+ value = url ["value" ]
30+ if "ccd.fnal.gov" in value :
31+ url ["value" ] = FIXED_URLS .get (value , value )
32+
33+
34+ FixFermilabURLs ()
You can’t perform that action at this time.
0 commit comments