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 86 of file ntuplePrintersDiff.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 87 of file ntuplePrintersDiff.py.

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

Member Function Documentation

◆ __len__()

def ntuplePrintersDiff._DiffResult.__len__ (   self)

Definition at line 156 of file ntuplePrintersDiff.py.

156  def __len__(self):
157  return len(self._diff)
158 

References ntuplePrintersDiff._DiffResult._diff.

◆ __str__()

def ntuplePrintersDiff._DiffResult.__str__ (   self)

Definition at line 153 of file ntuplePrintersDiff.py.

153  def __str__(self):
154  return "\n".join([s for s in (str(item) for item in self._diff) if s != ""])
155 

References ntuplePrintersDiff._DiffResult._diff, join(), and str.

◆ _highlightLine()

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

Definition at line 106 of file ntuplePrintersDiff.py.

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

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

◆ extend()

def ntuplePrintersDiff._DiffResult.extend (   self,
  diff 
)

Definition at line 98 of file ntuplePrintersDiff.py.

98  def extend(self, diff):
99  if isinstance(diff, _DiffResult):
100  self._diff.append(diff)
101  if diff.hasDifference():
102  self.setDifference()
103  else:
104  self._diff.extend(diff)
105 

References ntuplePrintersDiff._DiffResult._diff, mps_setup.append, and ntuplePrintersDiff._DiffResult.setDifference().

Referenced by MatrixUtil.WF.__init__().

◆ hasDifference()

def ntuplePrintersDiff._DiffResult.hasDifference (   self)

Definition at line 95 of file ntuplePrintersDiff.py.

95  def hasDifference(self):
96  return self._hasDifference
97 

References ntuplePrintersDiff._DiffResult._hasDifference.

◆ highlight()

def ntuplePrintersDiff._DiffResult.highlight (   self,
  plus = False,
  minus = False 
)

Definition at line 116 of file ntuplePrintersDiff.py.

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

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

◆ highlightLines()

def ntuplePrintersDiff._DiffResult.highlightLines (   self,
  plusregexs = [],
  minusregexs = [] 
)

Definition at line 126 of file ntuplePrintersDiff.py.

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

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

◆ lines()

def ntuplePrintersDiff._DiffResult.lines (   self)

Definition at line 145 of file ntuplePrintersDiff.py.

145  def lines(self):
146  for line in self._diff:
147  if isinstance(line, _DiffResult):
148  for l in line.lines():
149  yield l
150  else:
151  yield line
152 

References ntuplePrintersDiff._DiffResult._diff.

◆ setDifference()

def ntuplePrintersDiff._DiffResult.setDifference (   self,
  diff = True 
)

Definition at line 92 of file ntuplePrintersDiff.py.

92  def setDifference(self, diff=True):
93  self._hasDifference = diff
94 

References ntuplePrintersDiff._DiffResult._hasDifference.

Referenced by ntuplePrintersDiff._DiffResult.extend().

Member Data Documentation

◆ _diff

ntuplePrintersDiff._DiffResult._diff
private

◆ _hasDifference

ntuplePrintersDiff._DiffResult._hasDifference
private
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
str
#define str(s)
Definition: TestProcessor.cc:53
groupFilesInBlocks.lines
lines
Definition: groupFilesInBlocks.py:95
Exception
mps_setup.append
append
Definition: mps_setup.py:85
TriggerAnalyzer.__str__
def __str__(self)
Definition: TriggerAnalyzer.py:103