Next / Previous / Contents / Shipman's homepage

24.3. PageHeader.checkSite(): Verify correct location or station

This method checks the location or station code following the “@” at the beginning of the page header line. If the parent compiler has a .location attribute that is not None, we expect that location's location code; otherwise we expect the parent compiler's .station code.
# - - -   P a g e H e a d e r . c h e c k S i t e   - - -

    def checkSite(compiler, scan, rawSite):
        '''Verify correct location or station code.

          [ (compiler is a BaseCompiler object) and
            (scan is a Scan object) and
            (rawSite is a string) ->
              if (compiler.location is not None) and
              (rawSite matches compiler.location.locCode, case
              insensitive) ->
                return True
              else if (compiler.location is None) and
              (rawSite matches compiler.station.staNo) ->
                return True
              else ->
                Log()  +:=  error message
                return False ]
        #-- 1 --
        if  compiler.location is None:
            if (compiler.station.staNo != rawSite):
                scan.error("Wrong staation code '%s': expecting "
                    "'%s'" % (rawSite, compiler.station.staNo))
                return False
                return True
            if (compiler.location.locCode.upper() !=
                scan.error("Wrong location code '%s': expecting "
                    "'%s'" % (rawSite, compiler.location.locCode))
                return False
                return True