-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tidy up #144
Tidy up #144
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,13 @@ | |
logger = logging.getLogger(__name__) | ||
|
||
|
||
def merge_dicts(*dicts): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works but what benefit does it have over the previous implementation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I see, thanks |
||
final = {} | ||
for d in dicts: | ||
final = dict(final, **{k: v for k, v in d.items() if v}) | ||
return final | ||
|
||
|
||
def get_arxiv_metadata(paper_id) -> arxiv.Result: | ||
""" | ||
Get metadata from arxiv | ||
|
@@ -59,7 +66,7 @@ def add_metadata(data, paper_id): | |
metadata = get_arxiv_metadata(paper_id) | ||
if not metadata: | ||
return {} | ||
return dict({ | ||
return merge_dicts({ | ||
"authors": metadata.authors, | ||
"title": metadata.title, | ||
"date_published": metadata.published, | ||
|
@@ -71,7 +78,7 @@ def add_metadata(data, paper_id): | |
"primary_category": metadata.primary_category, | ||
"categories": metadata.categories, | ||
"version": get_version(metadata.get_short_id()), | ||
}, **data) | ||
}, data) | ||
|
||
|
||
def fetch_arxiv(url) -> Dict: | ||
|
@@ -91,4 +98,4 @@ def fetch_arxiv(url) -> Dict: | |
authors = data.get('authors') or paper.get("authors") or [] | ||
data['authors'] = [str(a).strip() for a in authors] | ||
|
||
return dict(data, **paper) | ||
return merge_dicts(data, paper) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just noticed while merging #97 into main that if there's a ParserError, the behaviour
"If the date couldn't be parsed, hope that later phases will be more successful"
is probably a typo. maybe you mean to log it or to return it as an error, but date_published probably ought to be None?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe just
pass
and have that as a comment, tooThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I modified it there, #97