Skip to content
This repository was archived by the owner on Oct 5, 2023. It is now read-only.

Commit ff6cd97

Browse files
authored
Merge pull request #80 from coreofscience/fix-missing-fields-raise
Do not take into account articles with missing fields
2 parents e9b06cc + 4b962bb commit ff6cd97

7 files changed

Lines changed: 27 additions & 19 deletions

File tree

.zenodo.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"description": "Translates isi web of knowledge files into python objects.",
33
"license": "MIT",
44
"title": "coreofscience/python-wostools",
5-
"version": "v2.0.6",
5+
"version": "v2.0.7",
66
"upload_type": "software",
77
"publication_date": "2018-08-13",
88
"creators": [
@@ -25,7 +25,7 @@
2525
"related_identifiers": [
2626
{
2727
"scheme": "url",
28-
"identifier": "https://github.com/coreofscience/python-wostools/tree/v2.0.6",
28+
"identifier": "https://github.com/coreofscience/python-wostools/tree/v2.0.7",
2929
"relation": "isSupplementTo"
3030
},
3131
{

HISTORY.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# History
22

3-
## 2.0.5 (2020-08-21)
3+
## 2.0.7 (2020-08-23)
4+
5+
- Remove from the collection those documents whose label is unknow or conflictive.
6+
7+
## 2.0.6 (2020-08-21)
48

59
- Accomodate for unknown fields in ISI WOS files.
610

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
test_suite="tests",
4343
tests_require=test_requirements,
4444
url="https://github.com/coreofscience/python-wostools",
45-
version="2.0.6",
45+
version="2.0.7",
4646
zip_safe=False,
4747
long_description_content_type="text/markdown",
4848
)

tests/test_article.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pytest_bdd import given, parsers, scenarios, then, when
77

88
from wostools.article import Article
9-
from wostools.exceptions import InvalidIsiLine, InvalidReference
9+
from wostools.exceptions import InvalidIsiLine, InvalidReference, MissingLabelFields
1010

1111
from wostools._testutils import Context
1212

@@ -286,7 +286,7 @@ def no_error_computing_label(label_context: Context[str]):
286286
@then("There's an error computing the label")
287287
def error_computing_label(label_context: Context[str]):
288288
with label_context.assert_error() as error:
289-
assert isinstance(error, ValueError)
289+
assert isinstance(error, MissingLabelFields)
290290

291291

292292
@then(parsers.parse("the article matches the {field:w} of the other"))

wostools/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
__author__ = """Core of Science"""
44
__email__ = "dev@coreofscience.com"
5-
__version__ = "2.0.6"
5+
__version__ = "2.0.7"
66

77
from wostools.article import Article
88
from wostools.lazy import LazyCollection

wostools/cached.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
import itertools
66
import logging
7+
from contextlib import suppress
78
from typing import Dict, Iterable, Iterator, Tuple
89

910
from wostools.article import Article
1011
from wostools.base import BaseCollection
11-
from wostools.exceptions import InvalidReference
12+
from wostools.exceptions import InvalidReference, MissingLabelFields
1213

1314
logger = logging.getLogger(__name__)
1415

@@ -40,14 +41,15 @@ def _preheat(self):
4041
if key == self._cache_key:
4142
return
4243
for article in self._articles():
43-
self._add_article(article)
44-
for reference in article.references:
45-
try:
46-
self._add_article(Article.from_isi_citation(reference))
47-
except InvalidReference:
48-
logger.info(
49-
f"Ignoring malformed reference '{reference}' from '{article.label}'"
50-
)
44+
with suppress(MissingLabelFields):
45+
self._add_article(article)
46+
for reference in article.references:
47+
try:
48+
self._add_article(Article.from_isi_citation(reference))
49+
except InvalidReference:
50+
logger.info(
51+
f"Ignoring malformed reference '{reference}' from '{article.label}'"
52+
)
5153
self._cache_key = key
5254

5355
def __iter__(self) -> Iterator[Article]:

wostools/lazy.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
import itertools
66
import logging
7+
from contextlib import suppress
78
from typing import Iterable, Tuple
89

910
from wostools.article import Article
1011
from wostools.base import BaseCollection
11-
from wostools.exceptions import InvalidReference
12+
from wostools.exceptions import InvalidReference, MissingLabelFields
1213

1314
logger = logging.getLogger(__name__)
1415

@@ -37,8 +38,9 @@ def _article_texts(self):
3738
yield article_text
3839

3940
def _articles(self) -> Iterable[Article]:
40-
for article_text in self._article_texts:
41-
yield Article.from_isi_text(article_text)
41+
with suppress(MissingLabelFields):
42+
for article_text in self._article_texts:
43+
yield Article.from_isi_text(article_text)
4244

4345
@property
4446
def authors(self) -> Iterable[str]:

0 commit comments

Comments
 (0)