Next / Previous / Contents / Shipman's homepage

14.2. Maps2004SpeciesSet.readLine()

This method breaks up the input line into fields and passes them to Section 13.6, “BaseSpeciesSet.addSpecies(): Add a new species line” to be added to self.

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

    def readLine(self, scan):
        '''Process one line of the authority file.
        '''

See Section 6, “scanFieldList(): A utility routine for flat-file scanning”.

baseclasses.py
        #-- 1 --
        # [ if line in scan starts with the fields represented
        #   by self.FIELD_LIST ->
        #     scan  :=  scan advanced past those fields
        #     fieldSet  :=  a tuple of the fields in that order
        #   else ->
        #     Log()  +:=  error message(s)
        #     raise IOError ]
        fieldSet = scanFieldList(scan, self.FIELD_LIST)

It is critical that the next line lists the destination variables in the same order as in self.FIELD_LIST.

baseclasses.py
        #-- 2 --
        (ssn, eno, spNo, spec4, bblSpec, eng, fillers, genus,
         species, spec6) = fieldSet

Now that we have all the fields necessary, we create a new Species object and pass it to self.addSpecies. The .rstrip() method removes trailing whitespace from the English name.

baseclasses.py
        #-- 3 --
        species = Species(spNo, spec4, spec6, eng.rstrip())

See Section 13.6, “BaseSpeciesSet.addSpecies(): Add a new species line”.

baseclasses.py
        #-- 4 --
        # [ if (species.spec4 duplicates a key in self.spec4Map,
        #   case-insensitive) or
        #   (species.eng duplicates a key in self.engMap) ->
        #     Log()  +:=  error message(s)
        #     raise IOError
        #   else ->
        #     self.spec4Map  :=  an entry mapping species.spec4.upper()
        #                        |-> species
        #     self.spec6Map  :=  an entry mapping species.spec6.upper()
        #                        |-> species
        #     self.engMap  :=  an entry mapping species.eng |-> species ]
        self.addSpecies(species)