SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SciPost
SciPost
Commits
012845eb
Commit
012845eb
authored
7 years ago
by
Geert Kapteijns
Browse files
Options
Downloads
Patches
Plain Diff
Start work on new ArxivCaller
parent
d8e76207
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scipost/services.py
+44
-6
44 additions, 6 deletions
scipost/services.py
scipost/test_services.py
+6
-0
6 additions, 0 deletions
scipost/test_services.py
with
50 additions
and
6 deletions
scipost/services.py
+
44
−
6
View file @
012845eb
...
...
@@ -22,7 +22,7 @@ class DOICaller:
request
=
requests
.
get
(
url
)
if
request
.
ok
:
self
.
is_valid
=
True
self
.
_crossref_data
=
request
s
.
get
(
url
)
.
json
()[
'
message
'
]
self
.
_crossref_data
=
request
.
json
()[
'
message
'
]
else
:
self
.
is_valid
=
False
...
...
@@ -65,6 +65,48 @@ class DOICaller:
return
pub_date
class
ArxivCaller
:
query_base_url
=
'
http://export.arxiv.org/api/query?id_list=%s
'
def
__init__
(
self
,
identifier
):
self
.
identifier
=
identifier
self
.
_call_arxiv
()
if
self
.
is_valid
:
self
.
_format_data
()
def
_call_arxiv
(
self
):
url
=
self
.
query_base_url
%
self
.
identifier
request
=
requests
.
get
(
url
)
if
request
.
ok
:
self
.
is_valid
=
True
self
.
_arxiv_data
=
feedparser
.
parse
(
request
.
content
)
else
:
self
.
is_valid
=
False
def
_format_data
(
self
):
raise
NotImplementedError
# metadata = caller.metadata
# pub_title = metadata['entries'][0]['title']
# authorlist = metadata['entries'][0]['authors'][0]['name']
# for author in metadata['entries'][0]['authors'][1:]:
# authorlist += ', ' + author['name']
# arxiv_link = metadata['entries'][0]['id']
# abstract = metadata['entries'][0]['summary']
#
# initialdata = {
# 'type': 'preprint',
# 'metadata': metadata,
# 'pub_title': pub_title,
# 'author_list': authorlist,
# 'arxiv_identifier': identifierform.cleaned_data['identifier'],
# 'arxiv_link': arxiv_link,
# 'pub_abstract': abstract
# }
# I'm going to revamp this whole thing...
class
BaseCaller
(
object
):
...
...
@@ -216,12 +258,8 @@ class BaseCaller(object):
return
t
.
render
(
Context
(
self
.
errorvariables
))
# class DOICaller(BaseCaller):
# """Perform a DOI lookup for a given identifier."""
# pass
class
ArxivCaller
(
BaseCaller
):
class
ArxivCaller
Old
(
BaseCaller
):
"""
Performs an Arxiv article lookup for given identifier
"""
# State of the caller
...
...
This diff is collapsed.
Click to expand it.
scipost/test_services.py
+
6
−
0
View file @
012845eb
...
...
@@ -6,7 +6,13 @@ from submissions.models import Submission
class
ArxivCallerTest
(
TestCase
):
def
setUp
(
self
):
self
.
valid_arxiv_identifier
=
'
1612.07611v1
'
def
test_collects_metadata
(
self
):
raise
NotImplementedError
class
ArxivCallerTestOld
(
TestCase
):
def
test_correct_lookup
(
self
):
caller
=
ArxivCaller
(
Submission
,
'
1611.09574v1
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment