Identical to spec2004 except for the name
of the species authority object.
#!/usr/bin/env python
#================================================================
# spec2002: Look up species code in the MAWS 2002 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():
'''spec2002 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 Maws2002SpeciesSet authority file is readable and
# valid ->
# speciesSet := a new Maws2002SpeciesSet object
# representing that file
# else ->
# sys.stderr +:= error message(s)
# stop execution ]
try:
speciesSet = Maws2002SpeciesSet()
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()