This concrete class represents an authority file in the MAPS 2004 format. For the format of this file, see the specification.
Unlike the base class, note that you do not need to provide the name of the authority file to the constructor.
# - - - - - c l a s s M a p s 2 0 0 4 S p e c i e s S e t - - - - - class Maps2004SpeciesSet(BaseSpeciesSet): '''For 2004-format MAPS authority files. Exports: Maps2004SpeciesSet(): [ if the MAPS 2004 species code authority file is in the current directory, readable and valid -> return a Maps2004SpeciesSet object that represents that file else -> raise IOError ] '''
We start out this concrete class with some manifest constants.
FILLER_L is the total length of a series
of fields that are not used by this object:
PNO, length 1.
FILLER_L = 24
Next we declare a list of field names and lengths in the 2004
MAPS species authority file. This list is in a form that can be
passed to Section 6, “
scanFieldList(): A utility routine
for flat-file scanning”.
FIELD_LIST = [ ("SSN", SPEC_NO_L), ("ENO", ENO_L), ("NUMB", SPEC_NO_L), ("SPEC4", SPEC4_L), ("BBLSPEC", SPEC4_L), ("COMMONNAME", ENG_L), ("fillers", FILLER_L), ("GENUS", GENUS_L), ("SPECIES", SPECIES_L), ("SPEC6", SPEC6_L) ]
Finally, here is the name of the species authority file used by this class.
AUTHORITY_FILE = "spcode04.txt"
Because this class knows the name of its authority file,
we provide a derived constructor that calls the parent
constructor with the correct name. See Section 13.4, “
# - - - M a p s 2 0 0 4 S p e c i e s S e t . _ _ i n i t _ _ - - - def __init__(self): '''Constructor for Maps2004SpeciesSet ''' BaseSpeciesSet.__init__(self, self.AUTHORITY_FILE)