LSSTApplications  18.1.0
LSSTDataManagementBasePackage
policyContinued.py
Go to the documentation of this file.
1 
2 __all__ = []
3 
4 from .policy import Policy
5 
6 from lsst.utils import continueClass
7 
8 
9 @continueClass # noqa F811 redefinition
10 class Policy:
11  def get(self, name):
12  type = self.getValueType(name)
13  if (type == self.UNDEF):
14  return self.getInt(name) # will raise an exception
15  # raise NameNotFound("Policy parameter name not found: " + name)
16 
17  if (type == self.INT):
18  return self.getInt(name)
19  elif (type == self.DOUBLE):
20  return self.getDouble(name)
21  elif (type == self.BOOL):
22  return self.getBool(name)
23  elif (type == self.STRING):
24  return self.getString(name)
25  elif (type == self.POLICY):
26  return self.getPolicy(name)
27  elif (type == self.FILE):
28  return self.getFile(name)
29 
30  def getArray(self, name):
31  type = self.getValueType(name)
32  if (type == self.UNDEF):
33  return self.getIntArray(name) # will raise an exception
34  # raise NameNotFound("Policy parameter name not found: " + name)
35 
36  if (type == self.INT):
37  return self.getIntArray(name)
38  elif (type == self.DOUBLE):
39  return self.getDoubleArray(name)
40  elif (type == self.BOOL):
41  return self.getBoolArray(name)
42  elif (type == self.STRING):
43  return self.getStringArray(name)
44  elif (type == self.POLICY):
45  return self.getPolicyArray(name)
46  elif (type == self.FILE):
47  return self.getFileArray(name)
48 
49  def set(self, name, value):
50  if (value is None):
51  raise RuntimeError("Attempt to set value of \"" + name +
52  "\" to None. Values must be non-None. Use remove() instead.")
53  else:
54  self._set(name, value)