Next / Previous / Contents / Shipman's homepage

25.2. Prefix.scanLine(): Scan a band prefix line

This static method checks the line in the given Scan object to see if it contains exactly seven characters. No other checking is done.

baseclasses.py
# - - -   P r e f i x . s c a n   - - -

    @staticmethod
    def scanLine(scan):
        '''Scan a band prefix line.
        '''
        #-- 1 --
        # [ scan  :=  scan advanced to end of line
        #   text  :=  remaining text on the line in scan, uppercased ]
        text = scan.tab(-1).upper()

See Section 25, “class Prefix: Band number prefix line”.

baseclasses.py
        #-- 2 --
        # [ if text is not PREFIX_L characters long ->
        #     Log()  +:=  error message
        #     raise SyntaxError
        #   else ->
        #     return a new Prefix object with text=text ]
        if  len(text) != PREFIX_L:
            message = ("Prefix '%s' is not exactly %d "
                "characters long." % (text, PREFIX_L))
            scan.syntax(message)
        else:
            return Prefix(text)