Skip to content

Commit 322e7d0

Browse files
committed
update from_partial_doi class method
1 parent 30ee364 commit 322e7d0

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

allofplos/article.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
from . import get_corpus_dir
1111
from .transformations import (filename_to_doi, _get_base_page, LANDING_PAGE_SUFFIX,
12-
URL_SUFFIX, plos_page_dict, doi_url, doi_to_url, doi_to_path)
12+
URL_SUFFIX, plos_page_dict, doi_url, doi_to_url, doi_to_path,
13+
partial_to_doi)
1314
from .plos_regex import validate_doi, find_valid_partial_dois
1415
from .elements import (parse_article_date, get_contrib_info,
1516
Journal, License, match_contribs_to_dicts)
@@ -1343,17 +1344,13 @@ def from_filename(cls, filename):
13431344
return cls(filename_to_doi(filename), directory=directory)
13441345

13451346
@classmethod
1346-
def from_partial_doi(cls, partial_doi):
1347+
def from_partial_doi(cls, partial_doi, directory=None):
13471348
"""Initiate an article object using a partial DOI.
13481349
Uses regex to make sure it's a valid partial DOI.
13491350
Used for internal PLOS methods.
13501351
"""
1351-
doi = ''
1352-
if len(find_valid_partial_dois(partial_doi)) == 1:
1353-
if 'annotation' in partial_doi:
1354-
doi = '10.1371/' + partial_doi
1355-
else:
1356-
doi = '10.1371/journal.' + partial_doi
1357-
else:
1358-
print(find_valid_partial_dois(partial_doi))
1359-
return cls(doi)
1352+
if directory is None:
1353+
directory = get_corpus_dir()
1354+
doi = partial_to_doi(partial_doi)
1355+
1356+
return cls(doi, directory=directory)

0 commit comments

Comments
 (0)