This static method processes a page header line. We assume
that the initial PAGE_SYMBOL character has
already been skipped.
# - - - P a g e H e a d e r . s c a n L i n e - - -
@staticmethod
def scanLine(compiler, scan):
'''Scan a page header line.
'''
#-- 1 --
# [ fieldList := fields from the line in scan that are
# separated by clumps of whitespace, uppercased ]
fieldList = scan.line[scan.pos:].upper().split()
See Section 24.3, “PageHeader.checkSite(): Verify correct
location or station”.
#-- 2 --
# [ if fieldList has exactly three members ->
# rawSite := fieldList[0]
# rawSize := fieldList[1]
# rawPageNo := fieldList[2]
# else ->
# Log() +:= error message
# raise SyntaxError ]
if len(fieldList) == 3:
rawSite, rawSize, rawPageNo = fieldList
else:
message = ("Expecting three fields (station or location, "
"band size, and page number.")
scan.syntax(message)
#-- 2 --
# [ if rawSite does not match the compiler's location or
# station code ->
# Log() +:= error message
# return
# else -> I ]
if not PageHeader.checkSite(compiler, scan, rawSite):
return
#-- 3 --
# [ if rawSize is longer than BAND_SIZE_L ->
# Log() +:= error message
# return
# else -> I ]
if len(rawSize) > BAND_SIZE_L:
message = ("Band size field '%s' too long; maximum "
"%d." % (rawSize, BAND_SIZE_L))
#-- 4 --
# [ if rawPageNo is longer than PAGE_NO_L ->
# Log() +:= error message
# return
# else -> I ]
if len(rawPageNo) > PAGE_NO_L:
message = ("Page number field '%s' too long; maximum "
"%d." % (rawPageNo, PAGE_NO_L))
See Section 24, “class PageHeader: Page header line
object”.
#-- 5 --
# [ return a new PageHeader object with size=rawSize and
# pageNo=rawPageNo ]
return PageHeader(rawSize, rawPageNo)