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, “
record routing dictionary”.
# - - - 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.
#-- 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
See Section 63.1, “
#-- 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.
Being at the end of the line at this point is always okay. If it's a single-station set, we don't expect a station code; it's implied from the set name. If there isn't a station code in a multi-station set, that's okay too because it may not have been recorded.
If we're not at the end of the line and it's a single-station set, that's an error—we don't expect a station code.
If we're not at the end of the line and it's a multi-station set, what remains must be the station code where the band was lost or destroyed.
#-- 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))