CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RelativeDataAccessor.py
Go to the documentation of this file.
1 class RelativeDataAccessor(object):
2  """ This class provides access to the underlying data model.
3  """
4 
5  def daughterRelations(self, object):
6  """ Return a list of the daughter relations of an object.
7  """
8  raise NotImplementedError
9 
10  def motherRelations(self, object):
11  """ Return a list of the mother relations of an object.
12  """
13  raise NotImplementedError
14 
15  def allDaughterRelations(self,object, list=None):
16  daughterRelations=[]
17  for child in self.daughterRelations(object):
18  if list==None or not child in list:
19  daughterRelations+=[child]
20  for grandchild in self.allDaughterRelations(child,daughterRelations):
21  daughterRelations+=[grandchild]
22  return daughterRelations
23 
24  def allMotherRelations(self,object, list=None):
25  motherRelations=[]
26  for mother in self.motherRelations(object):
27  if list==None or not mother in list:
28  motherRelations+=[mother]
29  for grandmother in self.allMotherRelations(motherRelations):
30  motherRelations+=[grandmother]
31  return motherRelations
32 
33  def hasRelations(self,object):
34  """ Return if object has relations.
35  """
36  return True