LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
LSSTDataManagementBasePackage
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | List of all members
lsst.pex.harness.dataset.Dataset Class Reference
Inheritance diagram for lsst.pex.harness.dataset.Dataset:

Public Member Functions

def __init__
 
def __eq__
 
def toString
 
def __str__
 
def toPolicy
 

Static Public Member Functions

def fromPolicy
 

Public Attributes

 type
 
 path
 
 valid
 
 ids
 

Private Member Functions

def _policy_
 

Detailed Description

a description of a dataset.  

This description is characterized by a dataset type name and a 
set of identifiers.  These attributes are access via public member 
variables 'type' (a string) and ids (a dictionary), respectively.

Definition at line 33 of file dataset.py.

Constructor & Destructor Documentation

def lsst.pex.harness.dataset.Dataset.__init__ (   self,
  type,
  path = None,
  valid = True,
  ids = None,
  kw 
)
create the dataset
@param type    the dataset type name
@param path    a filesystem pathname to the file.  If None, the 
         path is not known/applicable
@param valid   a boolean flag indicating whether this refers to
         valid dataset.  This is set to False, for example,
         if the dataset was not successfully created.
@param ids     a dictionary of identifiers, mapping names to values.
         the type of the identifier is context specific.
@param *       additional named parameters are taken as 
         identifiers to be set with the given values

Definition at line 42 of file dataset.py.

42 
43  def __init__(self, type, path=None, valid=True, ids=None, **kw):
44  """
45  create the dataset
46  @param type the dataset type name
47  @param path a filesystem pathname to the file. If None, the
48  path is not known/applicable
49  @param valid a boolean flag indicating whether this refers to
50  valid dataset. This is set to False, for example,
51  if the dataset was not successfully created.
52  @param ids a dictionary of identifiers, mapping names to values.
53  the type of the identifier is context specific.
54  @param * additional named parameters are taken as
55  identifiers to be set with the given values
56  """
57  self.type = type
58  self.path = path
59  self.valid = valid
60 
61  self.ids = None
62  if ids:
63  self.ids = dict(ids)
64  if kw:
65  if self.ids is None:
66  self.ids = {}
67  for key in kw.keys():
68  self.ids[key] = kw[key]

Member Function Documentation

def lsst.pex.harness.dataset.Dataset.__eq__ (   self,
  other 
)
return True if the given Dataset describes the same data as this
one.  

Definition at line 69 of file dataset.py.

69 
70  def __eq__(self, other):
71  """
72  return True if the given Dataset describes the same data as this
73  one.
74  """
75  if not isinstance(other, Dataset):
76  return False
77  if other.type != self.type:
78  return False
79  if len(filter(lambda d: d.ids is None, [self, other])) == 1:
80  return False
81 
82  keys = other.ids.keys()
83  if len(keys) != len(self.ids):
84  return False
85  for key in keys:
86  if not self.ids.has_key(key) or other.ids[key] != self.ids[key]:
87  return False
88  return True
def lsst.pex.harness.dataset.Dataset.__str__ (   self)

Definition at line 104 of file dataset.py.

105  def __str__(self):
106  return self.toString()
def lsst.pex.harness.dataset.Dataset._policy_ (   self)
private

Definition at line 129 of file dataset.py.

130  def _policy_(self):
131  return self.toPolicy()
def lsst.pex.harness.dataset.Dataset.fromPolicy (   policy)
static
unserialize a dataset description from a policy

Definition at line 133 of file dataset.py.

134  def fromPolicy(policy):
135  """
136  unserialize a dataset description from a policy
137  """
138  valid = type = ids = path = None
139 
140  if policy.exists("type"): type = policy.getString("type")
141  if policy.exists("path"): path = policy.getString("path")
142  if policy.exists("valid"): valid = policy.getBool("valid")
143  if policy.exists("ids"):
144  idp = policy.getPolicy("ids")
145  ids = {}
146  for name in idp.paramNames():
147  ids[name] = idp.get(name)
148 
149  return Dataset(type, path, valid, ids)
150 
151 
152 
def lsst.pex.harness.dataset.Dataset.toPolicy (   self,
  policy = None 
)
return a policy that describes this dataset.
@param policy    a policy instance to write into.  If not provided
           (default) a new one is created.
@return Policy   the policy containing the description of this dataset.

Definition at line 107 of file dataset.py.

108  def toPolicy(self, policy=None):
109  """
110  return a policy that describes this dataset.
111  @param policy a policy instance to write into. If not provided
112  (default) a new one is created.
113  @return Policy the policy containing the description of this dataset.
114  """
115  if not policy:
116  policy = Policy()
117  if self.type: policy.set("type", self.type)
118 
119  if self.ids:
120  ids = Policy()
121  policy.set("ids", ids)
122  for id in self.ids.keys():
123  ids.set(id, self.ids[id])
124 
125  if self.path: policy.set("path", self.path)
126  if self.valid is not None: policy.set("valid", self.valid)
127 
128  return policy
a container for holding hierarchical configuration data in memory.
Definition: Policy.h:169
def lsst.pex.harness.dataset.Dataset.toString (   self,
  usePath = True 
)
return a string form if this dataset's contents
@param usePath   if true, the path will be used available

Definition at line 89 of file dataset.py.

89 
90  def toString(self, usePath=True):
91  """
92  return a string form if this dataset's contents
93  @param usePath if true, the path will be used available
94  """
95  if usePath and self.path:
96  return self.path
97  out = self.type
98  if self.ids is not None:
99  names = self.ids.keys()
100  names.sort()
101  for id in names:
102  out += "-%s%s" % (id, self.ids[id])
103  return out

Member Data Documentation

lsst.pex.harness.dataset.Dataset.ids

Definition at line 60 of file dataset.py.

lsst.pex.harness.dataset.Dataset.path

Definition at line 57 of file dataset.py.

lsst.pex.harness.dataset.Dataset.type

Definition at line 56 of file dataset.py.

lsst.pex.harness.dataset.Dataset.valid

Definition at line 58 of file dataset.py.


The documentation for this class was generated from the following file: