Next / Previous / Contents / Shipman's homepage

87.5. spec1998

Also identical to spec2004 except for the name of the species authority object.

spec1998
#!/usr/bin/env python
#================================================================
# spec1998:  Look up species code in the MAPS 1998 authority file.
# For documentation, see:
#   http://www.nmt.edu/~shipman/z/ibp/doc/iband7/ims/
#----------------------------------------------------------------

#================================================================
# Imports
#----------------------------------------------------------------

import sys
import re
from baseclasses import *

# - - -   m a i n   - - -

def main():
    '''spec1998 main program
    '''
    #-- 1 --
    # [ if sys.argv contains exactly one argument ->
    #     target  :=  that argument
    #   else ->
    #     sys.stderr  +:=  error message(s)
    #     stop execution ]
    argList = sys.argv[1:]
    if  len(argList) != 1:
        print >>sys.stderr,("*** Takes one argument, the code "
            "or regular expression to be searched for.")
        sys.exit(1)
    else:
        target = argList[0]

    #-- 2 --
    # [ if the Maps1998SpeciesSet authority file is readable and
    #   valid ->
    #     speciesSet  :=  a new Maps1998SpeciesSet object
    #                     representing that file
    #   else ->
    #     sys.stderr  +:=  error message(s)
    #     stop execution ]
    try:
        speciesSet = Maps1998SpeciesSet()
    except IOError, detail:
        print >>sys.stderr,("*** Can't read the species authority "
            "file: %s" % detail)
        sys.exit(1)

    #-- 3 --
    # [ searcher  :=  a new SpeciesSearcher object that searches
    #       speciesSet for target ]
    searcher = SpeciesSearcher(speciesSet, target)

    #-- 4 --
    # [ sys.stdout  +:=  output of searcher ]
    searcher.run()

#================================================================
# Epilogue
#----------------------------------------------------------------

if  __name__ == "__main__":
    main()