|
9 | 9 |
|
10 | 10 | from . import get_corpus_dir |
11 | 11 | 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) |
13 | 14 | from .plos_regex import validate_doi, find_valid_partial_dois |
14 | 15 | from .elements import (parse_article_date, get_contrib_info, |
15 | 16 | Journal, License, match_contribs_to_dicts) |
@@ -1343,17 +1344,13 @@ def from_filename(cls, filename): |
1343 | 1344 | return cls(filename_to_doi(filename), directory=directory) |
1344 | 1345 |
|
1345 | 1346 | @classmethod |
1346 | | - def from_partial_doi(cls, partial_doi): |
| 1347 | + def from_partial_doi(cls, partial_doi, directory=None): |
1347 | 1348 | """Initiate an article object using a partial DOI. |
1348 | 1349 | Uses regex to make sure it's a valid partial DOI. |
1349 | 1350 | Used for internal PLOS methods. |
1350 | 1351 | """ |
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