-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
21,261 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class WrongInput(Exception): | ||
def __init__(self, input, current_year): | ||
super().__init__( | ||
f"Wrong input. Input should be digits and in range of 2004 to {current_year}: {input}" | ||
) | ||
|
||
|
||
class DataFetchError(Exception): | ||
def __init__(self, status_code, url): | ||
super().__init__(f"Data fetch failure, status_code={status_code}, url={url}") | ||
|
||
|
||
class NotFoundTotalCountOfRecords(Exception): | ||
def __init__( | ||
self, | ||
): | ||
super().__init__("Total count of records is not found!") | ||
|
||
|
||
class TypeDoesNotExist(Exception): | ||
def __init__(self, type_string, all_types): | ||
super().__init__( | ||
f"{type_string} this type does not exist, Available types: {all_types}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
CLOSED_ACCESS = ( | ||
r"not+540__a:'CC+BY'+not+540__a:'CC-BY'+" + r"not+540__f:Bronze+not+540__3:preprint" | ||
) | ||
BRONZE_ACCESS = r"540__f:'Bronze'" | ||
GREEN_ACCESS = ( | ||
r"not+540__a:'CC+BY'+not+540__a:'CC-BY'+not+540__a:" | ||
+ r"'arXiv+nonexclusive-distrib'+not+540__f:'Bronze'" | ||
) | ||
GOLD_ACCESS = r"540__3:'publication'+and+" + r"(540__a:'CC-BY'+OR++540__a:'CC+BY')" | ||
|
||
CERN_READ_AND_PUBLISH = r"540__f:'CERN-RP" | ||
CERN_INDIVIDUAL_APCS = r"540__f:'CERN-APC'" | ||
SCOAP3 = r"540__f:'SCOAP3'" | ||
OTHER = r"540__f:'Other'" | ||
OTHER_COLLECTIVE_MODELS = r"540__f:'Collective'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import xml.etree.ElementTree as ET | ||
from io import StringIO | ||
|
||
|
||
def parse_without_names_spaces(xml): | ||
if type(xml) == str: | ||
it = ET.iterparse(StringIO(xml)) | ||
else: | ||
it = ET.iterparse(StringIO(xml.getvalue().decode("utf-8"))) | ||
for _, el in it: | ||
el.tag = el.tag.rpartition("}")[-1] | ||
root = it.root | ||
return root | ||
|
||
|
||
def get_golden_access_records_ids(data): | ||
xml = parse_without_names_spaces(data) | ||
records = xml.findall(".record") | ||
golden_access = [] | ||
for record in records: | ||
datafields = record.findall("datafield/[@tag='540']") | ||
if datafields is None: | ||
continue | ||
for datafield in datafields: | ||
record_type = datafield.find("subfield/[@code='3']") | ||
license = datafield.find("subfield/[@code='a']") | ||
if record_type is not None and license is not None: | ||
if ( | ||
"CC" in license.text | ||
and "BY" in license.text | ||
and record_type.text == "publication" | ||
): | ||
record_id = record.find("controlfield/[@tag='001']") | ||
if record_id is not None: | ||
doi = record_id.text | ||
golden_access.append(doi) | ||
return golden_access |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ pre-commit==3.6.2 | |
pytest==7.4.4 | ||
coverage==7.4.3 | ||
pytest-cov==4.1.0 | ||
pytest-datadir==1.5.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.