def __str__(self,indent=''): """ This function is used for printing the class. Assumptions: N/A Source: N/A Inputs: N/A Outputs: N/A Properties Used: N/A """ try: args = self._diff.__str__(indent) args += indent + '_base : ' + self._base.__repr__() + '\n' args += indent + ' tag : ' + self._base.tag + '\n' return args except AttributeError: return Data.__str__(self,indent)
def __str__(self,indent=''): try: args = self._diff.__str__(indent) args += indent + '_base : ' + self._base.__repr__() + '\n' args += indent + ' tag : ' + self._base.tag + '\n' return args except AttributeError: return Data.__str__(self,indent)
class Diffed_Data(Data): """ SUAVE.Core.DiffedData() """ def __defaults__(self): self.tag = 'config' self._base = Data() self._diff = Data() def __init__(self,base=None): if base is None: base = Data() self._base = base this = deepcopy(base) # deepcopy is needed here to build configs - Feb 2016, T. MacDonald Data.__init__(self,this) def store_diff(self): delta = diff(self,self._base) self._diff = delta def pull_base(self): try: self._base.pull_base() except AttributeError: pass self.update(self._base) self.update(self._diff) def __str__(self,indent=''): try: args = self._diff.__str__(indent) args += indent + '_base : ' + self._base.__repr__() + '\n' args += indent + ' tag : ' + self._base.tag + '\n' return args except AttributeError: return Data.__str__(self,indent) def finalize(self): ## dont do this here, breaks down stream dependencies # self.store_diff self.pull_base()
class Diffed_Data(Data): """ This is for creating a data new class where a different copy is saved. This is useful for creating a new configuration of a vehicle. Assumptions: N/A Source: N/A """ def __defaults__(self): """ A stub for all classes that come later Assumptions: N/A Source: N/A Inputs: N/A Outputs: N/A Properties Used: N/A """ self.tag = 'config' self._base = Data() self._diff = Data() def __init__(self,base=None): """ Initializes the new Diffed_Data() class through a deepcopy Assumptions: N/A Source: N/A Inputs: N/A Outputs: N/A Properties Used: N/A """ if base is None: base = Data() self._base = base this = deepcopy(base) # deepcopy is needed here to build configs - Feb 2016, T. MacDonald Data.__init__(self,this) def store_diff(self): """ Finds the differences and saves them Assumptions: N/A Source: N/A Inputs: N/A Outputs: N/A Properties Used: N/A """ delta = diff(self,self._base) self._diff = delta def pull_base(self): """ Updates the differences Assumptions: N/A Source: N/A Inputs: N/A Outputs: N/A Properties Used: N/A """ try: self._base.pull_base() except AttributeError: pass self.update(self._base) self.update(self._diff) def __str__(self,indent=''): """ This function is used for printing the class. Assumptions: N/A Source: N/A Inputs: N/A Outputs: N/A Properties Used: N/A """ try: args = self._diff.__str__(indent) args += indent + '_base : ' + self._base.__repr__() + '\n' args += indent + ' tag : ' + self._base.tag + '\n' return args except AttributeError: return Data.__str__(self,indent) def finalize(self): """ This just does a pull_base() Assumptions: N/A Source: N/A Inputs: N/A Outputs: N/A Properties Used: N/A """ ## dont do this here, breaks down stream dependencies # self.store_diff self.pull_base()