Next / Previous / Contents / Shipman's homepage

17.4. SpeciesSearcher.run4(): Four-letter code search

Searches self.speciesSet to see if it has a four-letter code that matches self.target.

baseclasses.py
# - - -   S p e c i e s S e a r c h e r . r u n 4   - - -

    def run4(self):
        '''Search for a 4-letter species code.
        '''

        #-- 1 --
        # [ if self.speciesSet has a 4-letter code matching
        #   self.target, case-insensitive ->
        #     species  :=  the Species object with that code
        #   else ->
        #     sys.stderr  +:=  error message(s)
        #     stop execution ]
        try:
            species = self.speciesSet.lookupSpec4(self.target)
        except KeyError:
            print "*** No such 4-letter code: '%s'" % self.target
            sys.exit(1)

        #-- 2 --
        # [ sys.stdout  +:=  species in string form ]
        print "  %s" % species