Package Peach :: Module fixup
[hide private]

Source Code for Module Peach.fixup

  1   
  2  ''' 
  3  Implementation of base Transformer class. 
  4   
  5  @author: Michael Eddington 
  6  @version: $Id: transformer.py 872 2008-05-12 17:56:54Z meddingt $ 
  7  ''' 
  8   
  9  # 
 10  # Copyright (c) 2005-2008 Michael Eddington 
 11  # Copyright (c) 2004-2005 IOActive Inc. 
 12  # 
 13  # Permission is hereby granted, free of charge, to any person obtaining a copy  
 14  # of this software and associated documentation files (the "Software"), to deal 
 15  # in the Software without restriction, including without limitation the rights  
 16  # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell  
 17  # copies of the Software, and to permit persons to whom the Software is  
 18  # furnished to do so, subject to the following conditions: 
 19  # 
 20  # The above copyright notice and this permission notice shall be included in     
 21  # all copies or substantial portions of the Software. 
 22  # 
 23  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  
 24  # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  
 25  # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE  
 26  # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  
 27  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
 28  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
 29  # SOFTWARE. 
 30  # 
 31   
 32  # Authors: 
 33  #   Michael Eddington (mike@phed.org) 
 34   
 35  # $Id: transformer.py 872 2008-05-12 17:56:54Z meddingt $ 
 36   
37 -class Fixup:
38 ''' 39 Fixup of values in the data model. This is done using by keeping 40 an internal list of references that can be resolved during 41 fixup(). Helper functions are provided in this base class for 42 resolving elements in the data model. 43 ''' 44
45 - def __init__(self):
46 ''' 47 Create fixup object 48 ''' 49 self.context = None 50 self.isInSelf = False
51
52 - def dofixup(self):
53 ''' 54 Wrapper around fixup() to prevent endless recurtion. Please 55 do not override me :) 56 ''' 57 58 if not self.isInSelf: 59 try: 60 self.isInSelf = True 61 return self.fixup() 62 finally: 63 self.isInSelf = False 64 65 else: 66 return None
67
68 - def fixup(self):
69 ''' 70 Perform the required fixup. OVERRIDE ME! 71 ''' 72 73 raise Exception("Error: Fixup not implemented yet!")
74
75 - def _findDataElementByName(self, name):
76 ''' 77 DEPRICATED! 78 79 Use self.context.findDataElementByName(name) instead! 80 81 Internal helper method that will locate a data element in 82 the data model by it's name. We will search starting at 83 our current data element's node level and look down then 84 up for the requested node. 85 86 To be more specific about a node you can use the dotted 87 name "Element1.ELement2". 88 ''' 89 90 if self.context == None: 91 raise Exception("Error: Fixup tried to use _findDataElementByName but we have no context!") 92 93 return self.context.findDataElementByName(name)
94
95 - def _getContextRoot(self):
96 ''' 97 DEPRICATED! 98 99 Use self.context.getRootOfDataMap() instead! 100 101 Inernal helper method that returns the root of the current 102 data model. 103 ''' 104 105 return self.context.getRootOfDataMap()
106 107 108 # end 109