rcComplStatus.py

Go to the documentation of this file.
00001 #!/usr/local/bin/python
00002 #
00003 #                               Copyright 2005
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__     = "2005/07/23 00:08:27"
00014 __updated__  = "$Date: 2005/09/22 00:29:30 $"
00015 __version__  = "$Revision: 1.4 $"
00016 __release__  = "$Name: HEAD $"
00017 __credits__  = "SLAC"
00018 
00019 import LICOS.copyright_SLAC
00020 
00021 class rcCompletionStatus(object):
00022   """!\brief Completion code manager class.
00023 
00024   This helper class provides methods to facilitate the management
00025   of completion codes.
00026   """
00027   __csDict = {
00028                      0: 'PASSED',
00029                     -1: 'UNDEFINED',
00030                     -2: 'ABORTED',
00031                     -3: 'FAILED',
00032                     -4: 'PASSED CONDITIONALLY',
00033                     -5: 'MARGINAL',
00034                     -6: 'OPERATOR ABORTED',
00035                     -7: 'INCOMPLETE',
00036                   }
00037 
00038   def getCompletionStatus(statStr):
00039     """!\brief Return the completion status code based on the description.
00040 
00041     \param statStr Completion status description
00042 
00043     \return Completion status code or None if it doesn't exist.
00044     """
00045     for (status, statusStr) in rcCompletionStatus.__csDict.items():
00046       if statusStr == statStr:
00047         return status
00048   getCompletionStatus = staticmethod(getCompletionStatus)
00049 
00050   def getCompletionStatusStr(self, status):
00051     """!\brief Return the completion status string based
00052     on the code.
00053 
00054     \param status Completion status code
00055 
00056     \return Completion status description or None if it doesn't exist.
00057     """
00058     if status in self.__csDict:
00059       return self.__csDict[status]
00060 
00061   def isCompletionStatus(self, status):
00062     """!\brief Check if \a status is already in the dictionary.
00063 
00064     \param status Completion status code
00065 
00066     \return True : If it is already defined.
00067             False: Otherwise
00068     """
00069     return (status in self.__csDict)
00070 
00071   def addCompletionStatus(self, status, statusStr):
00072     """!\brief Adds the new completion status code and its
00073     description to the dictionary.
00074 
00075     \param status    Completion status code
00076     \param statusStr Completion status description
00077 
00078     \return  0: If add is successful.
00079             -1: If status code already exists.
00080             -2: If a duplicate description was found.
00081     """
00082     if self.getCompletionStatus(statusStr) is not None:
00083       # Duplicate description
00084       return -2
00085     if status not in self.__csDict:
00086       self.__csDict[status] = statusStr
00087       # Status added successfully
00088       return 0
00089     else:
00090       # Already exists
00091       return -1
00092 
00093   def getAll(self):
00094     """!\brief Return the completion status dictionary
00095 
00096     \return Completion status dictionary.
00097     """
00098     return self.__csDict
00099 
00100 #-------------------------------------------------------------------------------

Generated on Thu Apr 27 20:52:43 2006 for LICOS L02-01-00 by doxygen 1.4.6-NO