regex.py 1022 Bytes
Newer Older
1
# *-* coding: utf-8 *-*
2 3
""" A collections of regular expression defining rules validating
fields content.
4 5

"""
6
# Valid Collaboration field:
7 8 9
#  - CMS Collaboration
#  - CMS and LHCb Collaborations
#  - ATLAS Collaboration, CMS Collaboration
10
#  - Heavy Flavour Averaging Group
11 12 13
#  - CTA Consortium
#  - any mixture of the above separated by a comma
#
LE GAC Renaud's avatar
LE GAC Renaud committed
14 15
REG_COLLABORATION = \
    r'^[A-Za-z0-9\-/, ]+([Cc]ollaboration|[Cc]onsortium|[Gg]roup)[s]?$'
16

17
# Valid Conference dates
18
#   - 3 Dec 2012
19 20 21
#   - 10-14 Dec 2012
#   - 28 Jun - 4 Jul 2012
#
22 23 24 25
reg1 = r'\d{1,2} [A-Z][a-z]{2} \d{4}'
reg2 = r'\d{1,2}-\d{1,2} [A-Z][a-z]{2} \d{4}'
reg3 = r'\d{1,2} [A-Z][a-z]{2} - \d{1,2} [A-Z][a-z]{2} \d{4}'
REG_CONF_DATES = r'%s|%s|%s' % (reg1, reg2, reg3)
26

27
# Valid Defence date
28 29 30 31
#  - 30 Dec 2012
#
REG_DEFENSE = r'\d{2} [A-Z][a-z]{2} \d{4}'

32
# Valid Submitted field
33 34
#  - 2012-12
#  - 2012-12-31
35
#
36
REG_SUBMITTED = r'\d{4}-\d{2}(-\d{2})?'
37 38 39 40

# Valid origin Field
REG_VALID_ORIGIN = \
    r'^http[s]?://[\w\.]+/record/\d+(, http://[\w\.]+/record/\d+)?$'