Next / Previous / Contents / Shipman's homepage

74.7. BaseEncounter.scanShort(): Scan lost or destroyed encounter line

This method parses encounter lines for destroyed and lost bands. For the line format, see the specification.

Its intended function is the generic one defined in Section 74.12, “BaseEncounter.dispatchMap: Encounter record routing dictionary”.

baseclasses.py
# - - -   B a s e E n c o u n t e r . s c a n S h o r t   - - -

    def scanShort(self, scan):
        '''Parse deleted/lost band lines.
        '''

Each record starts with the last two digits of the band string; the remaining digits come from compiler.prefix, assuming there is one.

baseclasses.py
        #-- 1 --
        # [ if scan starts with a valid band number suffix in
        #   the context of self.compiler ->
        #     scan  :=  scan advanced past that suffix
        #     self  :=  self with the full band number stored in
        #               attribute BAND_NO_ATTR
        #   else ->
        #     Log()  +:=  error message
        #     raise SyntaxError ]
        BandNoSuffix.scanField(self, scan, BAND_NO_ATTR)

The record may end at this point. If not, the next field expected is the month and day. If the field is missing, we put together a fake date using the year from compiler.year and "0000". See Section 63.1, “DateField.scanField().

baseclasses.py
        #-- 2 --
        # [ if scan is at end of line ->
        #     self.date  :=  a DateField object representing
        #         self.compiler.year+"0000"
        #     return
        #   else if scan starts with a date as DDMM ->
        #     scan  :=  scan advanced past that date
        #     self.date  :=  a DateField object representing
        #         self.compiler.year+(that date)
        #   else ->
        #     Log()  +:=  error message(s)
        #     raise SyntaxError ]
        if  scan.atEndLine():
            setattr(self, DATE_ATTR,
                    DateField(self,
                              self.compiler.year+'0000'))
            return
        else:
            DateField.scanField(self, scan, DATE_ATTR)

There is one more potential field: a station code. If we're at end of line, For single-station sets, we don't expect this, so it's an error in that case if we aren't at end of line.

See Section 66.1, “StationCodeField.scanField().

baseclasses.py
        #-- 3 --
        # [ if scan is at end of line ->
        #     return
        #   else if self.compiler.station is not None ->
        #     Log()  +:=  error message(s)
        #     raise SyntaxError
        #   else if scan starts with a station code ->
        #     scan  :=  scan advanced past that code
        #     self.(STATION_ATTR)  :=  a Station object from
        #         self.compiler.stationSet representing that code
        #   else ->
        #     Log()  +:=  error message(s)
        #     raise SyntaxError ]
        if  scan.atEndLine():
            return
        elif self.compiler.station is not None:
            scan.syntax("For single-station sets, nothing should "
                "follow the date field.")
        else:
            StationCodeField.scanField(self, scan,
                StationCodeField(self, STATION_ATTR))