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

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 88 of file ntuplePrintersDiff.py.

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

Member Function Documentation

◆ __len__()

def ntuplePrintersDiff._DiffResult.__len__ (   self)

Definition at line 157 of file ntuplePrintersDiff.py.

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

References ntuplePrintersDiff._DiffResult._diff.

◆ __str__()

def ntuplePrintersDiff._DiffResult.__str__ (   self)

Definition at line 154 of file ntuplePrintersDiff.py.

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

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

◆ _highlightLine()

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

Definition at line 107 of file ntuplePrintersDiff.py.

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

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

◆ extend()

def ntuplePrintersDiff._DiffResult.extend (   self,
  diff 
)

Definition at line 99 of file ntuplePrintersDiff.py.

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

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

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

References ntuplePrintersDiff._DiffResult._hasDifference.

◆ highlight()

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

Definition at line 117 of file ntuplePrintersDiff.py.

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

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

◆ highlightLines()

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

Definition at line 127 of file ntuplePrintersDiff.py.

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

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

◆ lines()

def ntuplePrintersDiff._DiffResult.lines (   self)

Definition at line 146 of file ntuplePrintersDiff.py.

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

References ntuplePrintersDiff._DiffResult._diff.

◆ setDifference()

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

Definition at line 93 of file ntuplePrintersDiff.py.

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

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:52
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