Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _is_arxiv(obj):
"""Return ``True`` if ``obj`` contains an arXiv identifier.
The ``idutils`` library only handles arXiv identifiers, e.g. strings
of the form ``arXiv:yymm.xxxxx``, but we sometimes have to deal with
arXiv references, which might contain more information separated by
a space. Therefore this helper wraps ``idutils`` to support this case.
"""
arxiv_test = obj.split()
if not arxiv_test:
return False
return idutils.is_arxiv(arxiv_test[0])
def arxiv_syntax_validation(form, field):
"""Validate ArXiv ID syntax."""
message = "The provided ArXiv ID is invalid - it should look \
similar to 'hep-th/9711200' or '1207.7235'."
if field.data and not is_arxiv(field.data):
raise StopValidation(message)
def arxiv_syntax_validation(form, field):
"""Validate ArXiv ID syntax."""
message = "The provided ArXiv ID is invalid - it should look \
similar to 'hep-th/9711200' or '1207.7235'."
if field.data and not is_arxiv(field.data):
raise StopValidation(message)