CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ntuplePrintersDiff._DiffResult Class Reference
Inheritance diagram for ntuplePrintersDiff._DiffResult:

Public Member Functions

def __init__ (self, diff=[], hasDifference=False)
 
def __len__ (self)
 
def __str__ (self)
 
def extend (self, diff)
 
def hasDifference (self)
 
def highlight (self, plus=False, minus=False)
 
def highlightLines (self, plusregexs=[], minusregexs=[])
 
def lines (self)
 
def setDifference (self, diff=True)
 

Private Member Functions

def _highlightLine (self, line, plus, minus)
 

Private Attributes

 _diff
 
 _hasDifference
 

Detailed Description

Definition at line 85 of file ntuplePrintersDiff.py.

Constructor & Destructor Documentation

def ntuplePrintersDiff._DiffResult.__init__ (   self,
  diff = [],
  hasDifference = False 
)

Definition at line 86 of file ntuplePrintersDiff.py.

86  def __init__(self, diff=[], hasDifference=False):
87  self._diff = []
88  self._hasDifference = hasDifference
89  self.extend(diff)
90 
def __init__(self, diff=[], hasDifference=False)

Member Function Documentation

def ntuplePrintersDiff._DiffResult.__len__ (   self)

Definition at line 155 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff._DiffResult._diff.

def ntuplePrintersDiff._DiffResult.__str__ (   self)
def ntuplePrintersDiff._DiffResult._highlightLine (   self,
  line,
  plus,
  minus 
)
private

Definition at line 105 of file ntuplePrintersDiff.py.

Referenced by ntuplePrintersDiff._DiffResult.highlight(), and ntuplePrintersDiff._DiffResult.highlightLines().

105  def _highlightLine(self, line, plus, minus):
106  char = " "
107  if line[0] == "+":
108  if plus: char = "+"
109  elif line[0] == "-":
110  if minus: char = "-"
111  elif line[0] == "?":
112  char = "?"
113  return line[0]+char+line[1:]
114 
def _highlightLine(self, line, plus, minus)
def ntuplePrintersDiff._DiffResult.extend (   self,
  diff 
)

Definition at line 97 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff._DiffResult.setDifference().

Referenced by MatrixUtil.WF.__init__().

97  def extend(self, diff):
98  if isinstance(diff, _DiffResult):
99  self._diff.append(diff)
100  if diff.hasDifference():
101  self.setDifference()
102  else:
103  self._diff.extend(diff)
104 
def setDifference(self, diff=True)
def ntuplePrintersDiff._DiffResult.hasDifference (   self)
def ntuplePrintersDiff._DiffResult.highlight (   self,
  plus = False,
  minus = False 
)

Definition at line 115 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff._DiffResult._diff, and ntuplePrintersDiff._DiffResult._highlightLine().

115  def highlight(self, plus=False, minus=False):
116  if not (plus or minus):
117  return
118 
119  for i, line in enumerate(self._diff):
120  if isinstance(line, _DiffResult):
121  line.highlight(plus, minus)
122  else:
123  self._diff[i] = self._highlightLine(line, plus, minus)
124 
def _highlightLine(self, line, plus, minus)
def highlight(self, plus=False, minus=False)
def ntuplePrintersDiff._DiffResult.highlightLines (   self,
  plusregexs = [],
  minusregexs = [] 
)

Definition at line 125 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff._DiffResult._diff, and ntuplePrintersDiff._DiffResult._highlightLine().

125  def highlightLines(self, plusregexs=[], minusregexs=[]):
126  if len(plusregexs) == 0 and len(minusregexs) == 0:
127  return
128 
129  for i, line in enumerate(self._diff):
130  if isinstance(line, _DiffResult):
131  raise Exception("highlightLines() is currently allowed only for text-only _DiffResult objects")
132  plus = False
133  minus = False
134  for p in plusregexs:
135  if p.search(line):
136  plus = True
137  break
138  for m in minusregexs:
139  if m.search(line):
140  plus = True
141  break
142  self._diff[i] = self._highlightLine(line, plus, minus)
143 
def highlightLines(self, plusregexs=[], minusregexs=[])
def _highlightLine(self, line, plus, minus)
def ntuplePrintersDiff._DiffResult.lines (   self)

Definition at line 144 of file ntuplePrintersDiff.py.

References ntuplePrintersDiff._DiffResult._diff.

144  def lines(self):
145  for line in self._diff:
146  if isinstance(line, _DiffResult):
147  for l in line.lines():
148  yield l
149  else:
150  yield line
151 
def ntuplePrintersDiff._DiffResult.setDifference (   self,
  diff = True 
)

Member Data Documentation

ntuplePrintersDiff._DiffResult._diff
private
ntuplePrintersDiff._DiffResult._hasDifference
private