Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions
CMFDiffTool.FieldDiff.FieldDiff Class Reference
Inheritance diagram for CMFDiffTool.FieldDiff.FieldDiff:
Inheritance graph
[legend]
Collaboration diagram for CMFDiffTool.FieldDiff.FieldDiff:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def getLineDiffs
def testChanges
def applyChanges
def ndiff

Static Public Attributes

string meta_type = "Field Diff"

Private Member Functions

def _parseField

Detailed Description

Text difference

Definition at line 5 of file FieldDiff.py.


Member Function Documentation

def CMFDiffTool.FieldDiff.FieldDiff._parseField (   self,
  value 
) [private]
Parse a field value in preparation for diffing

Definition at line 10 of file FieldDiff.py.

00010 
00011     def _parseField(self, value):
00012         """Parse a field value in preparation for diffing"""
00013         # Since we only want to compare a single field, make a
00014         # one-item list out of it
00015         return [value]

Here is the caller graph for this function:

Update the specified object with the difference

Definition at line 27 of file FieldDiff.py.

00027 
00028     def applyChanges(self, ob):
00029         """Update the specified object with the difference"""
00030         # Simplistic update
00031         self.testChanges(ob)
00032         if not self.same:
00033             setattr(ob, self.field, self.newValue)

Here is the call graph for this function:

Definition at line 16 of file FieldDiff.py.

00016 
00017     def getLineDiffs(self):
00018         a = self._parseField(self.oldValue)
00019         b = self._parseField(self.newValue)        
00020         return difflib.SequenceMatcher(None, a, b).get_opcodes()

Here is the call graph for this function:

Here is the caller graph for this function:

Return a textual diff

Definition at line 34 of file FieldDiff.py.

00034 
00035     def ndiff(self):
00036         """Return a textual diff"""
00037         r=[]
00038         a = self._parseField(self.oldValue)
00039         b = self._parseField(self.newValue)        
00040         for tag, alo, ahi, blo, bhi in self.getLineDiffs():
00041             if tag == 'replace':
00042                 plain_replace(a, alo, ahi, b, blo, bhi, r)
00043             elif tag == 'delete':
00044                 dump('-', a, alo, ahi, r)
00045             elif tag == 'insert':
00046                 dump('+', b, blo, bhi, r)
00047             elif tag == 'equal':
00048                 dump(' ', a, alo, ahi, r)
00049             else:
00050                 raise ValueError, 'unknown tag ' + `tag`
00051         return '\n'.join(r)
00052 
00053 InitializeClass(FieldDiff)

Here is the call graph for this function:

Test the specified object to determine if the change set will apply without errors

Definition at line 21 of file FieldDiff.py.

00021 
00022     def testChanges(self, ob):
00023         """Test the specified object to determine if the change set will apply without errors"""
00024         value = _getValue(ob, self.field)
00025         if not self.same and value != self.oldValue:
00026             raise ValueError, ("Conflict Error during merge", self.field, value, self.oldValue)
        

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

string CMFDiffTool.FieldDiff.FieldDiff.meta_type = "Field Diff" [static]

Definition at line 8 of file FieldDiff.py.


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