The MAPS 2004 body format is different from the MAPS
2006 body format in one particular: the alignment
character is not always ALIGNMENT_CHAR.
It may instead be an asterisk, which indicates a single
feather was pulled; this is output as a “P” in the pulled-feather field.
In the parent class, processing of the alignment column
is not driven by the BODY_FIELD_LIST, so we can use the inherited table to scan all the
fields through the time field.
# - - - M a p s 2 0 0 4 E n c o u n t e r . s c a n B o d y - - -
def scanBody(self, scan):
'''Scan encounter record body and tail.
[ scan is a Scan object ->
if scan contains a valid encounter body and tail in
the context of self ->
scan := scan advanced to end of line
self := self with all fields from that line added
else ->
Log() +:= error message(s)
raise SyntaxError ]
'''
See Section 7, “scanFieldItems(): Parse a sequence of
FieldItem objects”.
#-- 1 --
# [ if the line in scan starts with a sequence of valid
# fields as described by self.BODY_FIELD_LIST ->
# scan := scan advanced past those fields
# self := self with values of those fields stored by
# the attribute names in self.BODY_FIELD_LIST
# else ->
# scan := scan advanced no further than end of line
# Log() +:= error message(s)
# raise SyntaxError ]
scanFieldItems(self, self.BODY_FIELD_LIST, scan)
See Section 66.1, “StationCodeField.scanField()”.
#-- 2 --
# [ if (self.compiler is a multi-station set) and
# (line in scan starts with a valid station code in
# the context of self.compiler) ->
# scan := scan advanced past that field
# self.(STATION_ATTR) := a StationCodeField containing
# that field
# else if (self.compiler is a multi-station set) and
# (line in scan does not start with a valid station code in
# the context of self.compiler) ->
# scan := scan advanced no further than end of line
# Log() +:= error message(s)
# raise SyntaxError
# else ->
# self.(STATION_ATTR) := a StationCodeField containing
# self.compiler.station.staCode ]
if self.compiler.location is not None:
#-- 2.1 --
# [ if line in scan starts with a valid station code in
# the context of self.compiler ->
# scan := scan advanced past that field
# self.(STATION_ATTR) := a Station object representing
# that field
# else ->
# scan := scan advanced no further than end of line
# Log() +:= error message(s)
# raise SyntaxError ]
StationCodeField.scanField(self, scan, STATION_ATTR)
else:
setattr(self, STATION_ATTR,
StationCodeField(self,
self.compiler.station.staCode))
See Section 67.1, “Net2Field.scanField()”.
#-- 3 --
# [ if scan starts with a valid 2-character net field ->
# scan := scan advanced past that field
# self.(NET_ATTR) := that field
# else ->
# scan := scan advanced no further than end of line
# Log() +:= error message(s)
# raise SyntaxError ]
Net2Field.scanField(self, scan, NET_ATTR)
Here is where this method diverges from the inherited
version. We leave the alignment field to be handled in
our variant of the scanTail() method; see
Section 76.3, “Maps2004Encounter.scanTail()”.
#-- 4 --
# [ if the line in scan starts with a valid
# 2004 tail section ->
# scan := scan advanced to end of line
# self := self with values from the tail stored using
# attribute names from self.OUT_FIELD_LIST
# else ->
# scan := scan advanced no further than end of line
# Log() +:= error message(s)
# raise SyntaxError ]
self.scanTail(scan)