Next / Previous / Contents / Shipman's homepage

16. class Maws2002SpeciesSet

An instance of this class represents the 2002 species code authority file currently used for MAWS data. For the format of this file, see the specification.

This class is nearly identical to Section 14, “class Maps2004SpeciesSet except for the ordering of the fields on the line.

baseclasses.py
# - - - - -   c l a s s   M a w s 2 0 0 2 S p e c i e s S e t   - - - - -

class Maws2002SpeciesSet(BaseSpeciesSet):
    '''Represents the MAWS 2002 species authority file.

      Exports:
        Maws2002SpeciesSet():
          [ if the MAPS 1998 species code authority file is in
            the current directory, readable and valid ->
              return a Maws2002SpeciesSet object that represents
              that file
            else -> raise IOError ]


    '''
    FIELD_LIST = [
      ("NUMB",        SPEC_NO_L),
      ("SPEC4",       SPEC4_L),
      ("COMMONNAME",  ENG_L),
      ("SPEC6",       SPEC6_L) ]

    AUTHORITY_FILE = "spcode02.txt"

# - - -   M a w s 2 0 0 2 S p e c i e s S e t . _ _ i n i t _ _ - - -

    def __init__(self):
        '''Constructor for Maps2002SpeciesSet
        '''
        BaseSpeciesSet.__init__(self, self.AUTHORITY_FILE)

# - - -   M a w s 2 0 0 2 S p e c i e s S e t . r e a d L i n e   - - -

    def readLine(self, scan):
        '''Read a line from the MAWS 2002 species authority file.
        '''
        fieldSet = scanFieldList(scan, self.FIELD_LIST)
        (spNo, spec4, eng, spec6) = fieldSet
        species = Species(spNo, spec4, spec6, eng.rstrip())
        self.addSpecies(species)