Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

rcComplStatus.py

00001 #!/usr/local/bin/python
00002 #
00003 #                               Copyright 2004
00004 #                                     by
00005 #                        The Board of Trustees of the
00006 #                     Leland Stanford Junior University.
00007 #                            All rights reserved.
00008 #
00009 
00010 __facility__ = "Online"
00011 __abstract__ = "Completion status helper class"
00012 __author__   = "S. Tuvi <Stuvi@SLAC.Stanford.edu> SLAC - GLAST LAT I&T/Online"
00013 __date__     = ("$Date: 2004/11/24 01:07:47 $").split(' ')[1]
00014 __version__  = "$Revision: 2.5 $"
00015 __release__  = "$Name: R04-12-00 $"
00016 __credits__  = "SLAC"
00017 
00018 import LATTE.copyright_SLAC
00019 
00020 class rcCompletionStatus(object):
00021   """This helper class provides methods to facilitate the management
00022   of completion codes.
00023   """
00024   __csDict = {
00025                      0: 'PASSED',
00026                     -1: 'UNDEFINED',
00027                     -2: 'ABORTED',
00028                     -3: 'FAILED',
00029                     -4: 'PASSED CONDITIONALLY',
00030                     -5: 'MARGINAL',
00031                     -6: 'OPERATOR ABORTED',
00032                     -7: 'INCOMPLETE',
00033                   }
00034 
00035   def getCompletionStatus(statStr):
00036     """Return the completion status code based
00037     on the description.
00038 
00039     \param statStr Completion status description
00040 
00041     \return Completion status code or None if it doesn't exist.
00042     """
00043     for (status, statusStr) in rcCompletionStatus.__csDict.items():
00044       if statusStr == statStr:
00045         return status
00046   getCompletionStatus = staticmethod(getCompletionStatus)
00047 
00048   def getCompletionStatusStr(self, status):
00049     """Return the completion status string based
00050     on the code.
00051 
00052     \param status Completion status code
00053 
00054     \return Completion status description or None if it doesn't exist.
00055     """
00056     if status in self.__csDict:
00057       return self.__csDict[status]
00058 
00059   def isCompletionStatus(self, status):
00060     """Check if \a status is already in the dictionary.
00061 
00062     \param status Completion status code
00063 
00064     \return True : If it is already defined.
00065             False: Otherwise
00066     """
00067     return (status in self.__csDict)
00068 
00069   def addCompletionStatus(self, status, statusStr):
00070     """Adds the new completion status code and its
00071     description to the dictionary.
00072 
00073     \param status    Completion status code
00074     \param statusStr Completion status description
00075 
00076     \return  0: If add is successful.
00077             -1: If status code already exists.
00078             -2: If a duplicate description was found.
00079     """
00080     if self.getCompletionStatus(statusStr) is not None:
00081       # Duplicate description
00082       return -2
00083     if status not in self.__csDict:
00084       self.__csDict[status] = statusStr
00085       # Status added successfully
00086       return 0
00087     else:
00088       # Already exists
00089       return -1
00090 
00091   def getAll(self):
00092     return self.__csDict
00093 
00094 #-------------------------------------------------------------------------------

Generated on Fri Jul 21 13:26:31 2006 for LATTE R04-12-00 by doxygen 1.4.3