Next / Previous / Contents / Shipman's homepage

15. class Maps1998SpeciesSet

This derived class represents the old MAPS 1998-format species file. Again, the constructor does not require the name of the authority file.

baseclasses.py
# - - - - -   c l a s s   M a p s 1 9 9 8 S p e c i e s S e t   - - - - -

class Maps1998SpeciesSet(BaseSpeciesSet):
    '''For 1998-format MAPS authority files.

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

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

Note

The 1998 MAPS species authority file does not have a 6-letter code. Consequently, we just store the string "NOSUCH" in that field.

baseclasses.py
    FIELD_LIST = [
      ("SSN",         SPEC_NO_L),
      ("ENO",         ENO_L),
      ("NUMB",        SPEC_NO_L),
      ("SPEC4",       SPEC4_L),
      ("COMMONNAME",  ENG_L) ]

    AUTHORITY_FILE = "spcode98.txt"

See Section 13.4, “BaseSpeciesSet.__init__(): Constructor”.

baseclasses.py
# - - -   M a p s 1 9 9 8 S p e c i e s S e t . _ _ i n i t _ _ - - -

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

See Section 6, “scanFieldList(): A utility routine for flat-file scanning” and Section 18, “class Species: Definition of a species code”.

baseclasses.py
# - - -   M a p s 1 9 9 8 S p e c i e s S e t . r e a d L i n e   - - -

    def readLine(self, scan):
        '''Concrete method for the MAPS 1998 species line.
        '''
        fieldSet = scanFieldList(scan, self.FIELD_LIST)
        ssn, eno, spNo, spec4, eng = fieldSet
        species = Species(spNo, spec4, "NOSUCH", eng.rstrip())
        self.addSpecies(species)