Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _normalize_arxiv(obj):
"""Return a normalized arXiv identfier.
As in ``_is_arxiv``, we need to handle arXiv references as well
as arXiv identifiers. We also need to return a simpler arXiv
identifier than what ``idutils`` would output, so we use some
of its helpers instead of ``normalize_arxiv``.
"""
obj = obj.split()[0]
m = idutils.is_arxiv_pre_2007(obj)
if m:
return ''.join(m.group(2, 4, 5))
m = idutils.is_arxiv_post_2007(obj)
if m:
return '.'.join(m.group(2, 3))
def arxiv_id(self, key, value):
from idutils import is_arxiv_post_2007
if is_arxiv_post_2007(value):
arxiv_rep_number = {'value': 'arXiv:' + value}
else:
arxiv_rep_number = {'value': value}
if len(value.split('/')) == 2:
arxiv_rep_number['categories'] = value.split('/')[0]
if 'arxiv_eprints' in self:
self['arxiv_eprints'].append(arxiv_rep_number)
else:
self['arxiv_eprints'] = [arxiv_rep_number]
def arxiv_id(self, key, value):
if is_arxiv_post_2007(value):
arxiv_rep_number = {'value': 'arXiv:' + value}
else:
arxiv_rep_number = {'value': value}
if len(value.split('/')) == 2:
arxiv_rep_number['categories'] = value.split('/')[0]
if 'arxiv_eprints' in self:
self['arxiv_eprints'].append(arxiv_rep_number)
else:
self['arxiv_eprints'] = [arxiv_rep_number]
raise IgnoreKey
def get_primary_class(data, doc_type):
eprint = get_value(data, 'arxiv_eprints.value[0]')
if eprint and is_arxiv_post_2007(eprint):
return get_value(data, 'arxiv_eprints[0].categories[0]')
def curation_ticket_context(user, obj):
recid = obj.extra_data.get('recid')
record_url = obj.extra_data.get('url')
server_name = current_app.config['SERVER_NAME']
legacy_url = current_app.config['LEGACY_BASE_URL']
arxiv_ids = get_value(obj.data, 'arxiv_eprints.value') or []
for index, arxiv_id in enumerate(arxiv_ids):
if arxiv_id and is_arxiv_post_2007(arxiv_id):
arxiv_ids[index] = 'arXiv:{0}'.format(arxiv_id)
report_numbers = get_value(obj.data, 'report_numbers.value') or []
dois = [
"doi:{0}".format(doi)
for doi in get_value(obj.data, 'dois.value') or []
]
link_to_pdf = obj.extra_data.get('formdata', {}).get('url')
subject = ' '.join(filter(
lambda x: x is not None,
arxiv_ids + dois + report_numbers + ['(#{0})'.format(recid)]
))
references = obj.extra_data.get('formdata', {}).get('references')
user_comment = obj.extra_data.get('formdata', {}).get('extra_comments', '')
def get_curation_body(template, metadata, email, extra_data):
"""
Get ticket content.
Ticket used by curators to curate the given record.
"""
from idutils import is_arxiv_post_2007
recid = extra_data.get('recid')
record_url = extra_data.get('url')
arxiv_id = metadata.get('arxiv_id')
if arxiv_id and is_arxiv_post_2007(arxiv_id):
arxiv_id = ''.join(['arXiv:', arxiv_id])
report_number = metadata.get('report_numbers')
if report_number:
report_number = report_number[0].get('value')
link_to_pdf = extra_data.get('submission_data').get('pdf')
subject = ' '.join(filter(lambda x: x is not None,
[arxiv_id,
" ".join(["doi:{0}".format(d) for d in metadata.get('dois')]),
report_number,
'(#{0})'.format(recid)]))
references = extra_data.get('submission_data').get('references')
user_comment = extra_data.get('submission_data').get('extra_comments')