This class represents a four-character net field, such as in the MAWS 2007 protocol. See the specification.
This class is identical to Section 67, “class Net2Field: Two-character net
code”,
which see for more detailed comments.
# - - - - - c l a s s N e t 4 F i e l d - - - - -
class Net4Field(FieldItem):
'''Represents a two-character net field.
Exports: as inherited.
'''
# - - - N e t 4 F i e l d . s c a n F i e l d - - -
@staticmethod
def scanField(encounter, scan, fieldName):
'''Scan a two-character net field.
'''
#-- 1 --
# [ if the line in scan contains at least NET4_L characters ->
# scan := scan advanced NET4_L
# text := next NET4_L characters from scan, uppercased
# else ->
# Log() +:= error message
# raise SyntaxError ]
try:
text = scan.move(NET4_L).upper()
except IndexError:
scan.syntax("Expecting a %d-character net field." %
NET4_L)
#-- 2 --
setattr(encounter, NET_ATTR,
Net4Field(encounter, text))