Next / Previous / Contents / Shipman's homepage

76.4. Maps2004Encounter.scanOldAlign(): Scan old alignment or feather-pulled field

In two cases of the MAPS 2004 format (at the beginning of the short tail, or at the end of the long tail), we expect either an ALIGNMENT_CHAR, which has no semantic import, or an OLD_PULL_INPUT character, which means we need to set the encounter object's PULLED_ATTR to the feather-pulled character.

baseclasses.py
# - - -   M a p s 2 0 0 4 E n c o u n t e r . s c a n O l d A l i g n

    def scanOldAlign(self, scan):
        '''Scan the MAPS 2004 alignment-or-feather-pulled field.

          [ scan is a Scan object ->
              if the line in scan starts with ALIGNMENT_CHAR ->
                scan  :=  scan advanced 1
              else if the line in scan starts with OLD_PULL_INPUT ->
                scan  :=  scan advanced 1
                self.(PULLED_ATTR)  :=  OLD_PULL_OUTPUT
              else ->
                Log()  +:=  error message
                raise SyntaxError ]
        '''
        if  scan.tabMatch(ALIGNMENT_CHAR):
            pass
        elif  scan.tabMatch(OLD_PULL_INPUT):
            setattr(self, PULLED_ATTR,
                    PulledField(self, OLD_PULL_OUTPUT))
        else:
            scan.syntax("Expecting alignment (%s) or "
                "feather-pulled (%s) character." %
                (ALIGNMENT_CHAR, OLD_PULL_INPUT))