SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit d15aaa8d authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Add helper functions to randomly fill factories

parent 45d90fe0
No related branches found
No related tags found
No related merge requests found
import random
import string
from journals.constants import SCIPOST_JOURNALS_SUBMIT
def model_form_data(model, form_class, form_kwargs={}):
'''
......@@ -38,6 +40,34 @@ def random_arxiv_identifier_without_version_number():
return random_digits(4) + "." + random_digits(5)
def random_scipost_journal():
return random.choice(SCIPOST_JOURNALS_SUBMIT)[0]
def random_external_journal():
return random.choice((
'PhysRevA.',
'PhysRevB.',
'PhysRevC.',
'nature.'
'S0550-3213(01)',
'1742-5468/',
'0550-3213(96)'
))
def random_pub_number():
return '%i.%i.%s' % (random.randint(1, 9), random.randint(1, 9), random_digits(3))
def random_scipost_doi():
return '10.21468/%s.%s' % (random_scipost_journal(), random_pub_number())
def random_external_doi():
return '10.%s/%s%s' % (random_digits(5), random_external_journal(), random_pub_number())
def random_digits(n):
return "".join(random.choice(string.digits) for _ in range(n))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment