WRP (Wolfe-Ryder-Pyle) molt cycle code. For valid codes, see http://www.nmt.edu/~shipman/z/ibp/doc/iband7/sheet-wrp.
# - - - - - c l a s s W r p F i e l d
class WrpField(FieldItem):
'''Represents a Wolfe-Ryder-Pyle molt cycle code.
Exports, other than those inherited:
WrpField.scanField(encounter, scan, fieldName): # Static
[ (encounter is a BaseEncounter instance) and
(scan is a Scan instance) and
(fieldName is a field name in self.OUT_FIELD_LIST) ->
if scan starts with a valid WRP molt cycle code in
the context of encounter ->
scan := scan advanced past that field
encounter.(fieldName) := a WrpField instance
representing that fiel
else ->
scan := scan advanced no further than end of line
Log() +:= error message(s)
raise SyntaxError ]
WrpField.flatten(): [ as in base class ]
'''
# - - - W r p F i e l d . s c a n F i e l d
@staticmethod
def scanField(encounter, scan, fieldName):
'''Scan a WRP molt cycle code.
'''
#-- 1
# [ if scan has at least WRP_L characters ->
# scan := scan advanced by WRP_L
# rawCode := first WRP_L characters from scan, uppercased
# else ->
# Log() +:= error message
# raise SyntaxError ]
try:
rawCode = scan.move(WRP_L).upper()
except IndexError:
scan.syntax("Expect {0}-character WRP molt cycle "
"code.".format(WRP_L))
See Section 38.2, “WrpField._check(): Check a WRP code”.
#-- 2
# [ if rawCode is a valid WRP code ->
# encounter.(fieldName) := rawCode
# else ->
# Log() +:= error message
# raise SyntaxError ]
WrpField._check(encounter, scan, rawCode, fieldName)