regex.py 998 Bytes
Newer Older
1 2
""" A collections of regular expression defining rules validating
fields content.
3 4

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

16
# Valid Conference dates
17
#   - 3 Dec 2012
18 19 20
#   - 10-14 Dec 2012
#   - 28 Jun - 4 Jul 2012
#
LE GAC Renaud's avatar
LE GAC Renaud committed
21 22 23 24
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)
25

26
# Valid Defence date
27 28
#  - 30 Dec 2012
#
LE GAC Renaud's avatar
LE GAC Renaud committed
29
REG_DEFENSE = r"\d{2} [A-Z][a-z]{2} \d{4}"
30

31
# Valid Submitted field
32 33
#  - 2012-12
#  - 2012-12-31
34
#
LE GAC Renaud's avatar
LE GAC Renaud committed
35
REG_SUBMITTED = r"\d{4}-\d{2}(-\d{2})?"
36 37 38

# Valid origin Field
REG_VALID_ORIGIN = \
LE GAC Renaud's avatar
LE GAC Renaud committed
39
    r"^http[s]?://[\w\.]+/record/\d+(, http://[\w\.]+/record/\d+)?$"