This class uses the Singleton design pattern so that the first
constructor call processes all the CGI arguments and either
returns an instance, or raises ScriptError if
there is any problem. Successive calls to the constructor
return the same instance.
# - - - - - c l a s s R e g A r g s
class RegArgs(singleton.Singleton):
'''Represents the CGI arguments.
Exports:
RegArgs():
[ if the CGI arguments to this script are valid ->
return the singleton RegArgs instance representing
those arguments
else -> raise ScriptError ]
.firstYear:
[ if a valid FIRST_YEAR_ENTRY value was specified ->
that number in year-number format
else -> lib.MIN_YEAR ]
.lastYear:
[ if a valid LAST_YEAR_ENTRY value was specified ->
that number in year-number format
else -> lib.MAX_YEAR ]
.reg_code:
[ the required REG_RADIOS value ]
.isOverlap:
[ True iff overlap report requested ]
State/Invariants:
RegArgs.REG_CODE_PAT:
[ a compiled regex that matches valid region codes ]
'''
initialized = False
For year-number format, see Section 14.4, “year-number”.
The REG_CODE_PAT class constant is a compiled
regular expression used to check region codes for validity:
they must consist of exactly two letters. The final
“$” insures that the entire
string is matched.
REG_CODE_PAT = re.compile(r'[a-zA-Z]{2}$')