CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Public Attributes | Private Member Functions
svgfig.SVG Class Reference

Classes

class  SVGDepthIterator
 nested class More...
 

Public Member Functions

def __contains__ (self, value)
 
def __delitem__ (self, ti)
 
def __eq__ (self, other)
 
def __getitem__ (self, ti)
 
def __init__ (self, t_sub, attr)
 
def __iter__ (self)
 
def __ne__ (self, other)
 
def __repr__ (self)
 
def __setitem__ (self, ti, value)
 
def __str__ (self)
 
def append (self, x)
 
def breadth_first (self, depth_limit=None)
 
def clone (self, shallow=False)
 
def depth_first (self, depth_limit=None)
 end nested class More...
 
def extend (self, x)
 
def firefox (self, fileName=None, encoding="utf-8")
 
def inkscape (self, fileName=None, encoding="utf-8")
 
def inkview (self, fileName=None, encoding="utf-8")
 
def interpret_fileName (self, fileName=None)
 
def items (self, sub=True, attr=True, text=True)
 
def keys (self, sub=True, attr=True, text=True)
 
def prepend (self, x)
 
def save (self, fileName=None, encoding="utf-8", compresslevel=None)
 
def standalone_xml (self, indent=" ", newl="\n")
 
def tree (self, depth_limit=None, sub=True, attr=True, text=True, tree_width=20, obj_width=80)
 
def values (self, sub=True, attr=True, text=True)
 
def xml (self, indent=" ", newl="\n", depth_limit=None, depth=0)
 

Public Attributes

 attr
 
 sub
 
 t
 

Private Member Functions

def __standalone_xml (self, indent, newl)
 

Detailed Description

A tree representation of an SVG image or image fragment.

SVG(t, sub, sub, sub..., attribute=value)

t                       required             SVG type name
sub                     optional list        nested SVG elements or text/Unicode
attribute=value pairs   optional keywords    SVG attributes

In attribute names, "__" becomes ":" and "_" becomes "-".

SVG in XML

<g id="mygroup" fill="blue">
    <rect x="1" y="1" width="2" height="2" />
    <rect x="3" y="3" width="2" height="2" />
</g>

SVG in Python

>>> svg = SVG("g", SVG("rect", x=1, y=1, width=2, height=2), \ 
...                SVG("rect", x=3, y=3, width=2, height=2), \ 
...           id="mygroup", fill="blue")

Sub-elements and attributes may be accessed through tree-indexing:

>>> svg = SVG("text", SVG("tspan", "hello there"), stroke="none", fill="black")
>>> svg[0]
<tspan (1 sub) />
>>> svg[0, 0]
'hello there'
>>> svg["fill"]
'black'

Iteration is depth-first:

>>> svg = SVG("g", SVG("g", SVG("line", x1=0, y1=0, x2=1, y2=1)), \
...                SVG("text", SVG("tspan", "hello again")))
... 
>>> for ti, s in svg:
...     print ti, repr(s)
... 
(0,) <g (1 sub) />
(0, 0) <line x2=1 y1=0 x1=0 y2=1 />
(0, 0, 'x2') 1
(0, 0, 'y1') 0
(0, 0, 'x1') 0
(0, 0, 'y2') 1
(1,) <text (1 sub) />
(1, 0) <tspan (1 sub) />
(1, 0, 0) 'hello again'

Use "print" to navigate:

>>> print svg
None                 <g (2 sub) />
[0]                      <g (1 sub) />
[0, 0]                       <line x2=1 y1=0 x1=0 y2=1 />
[1]                      <text (1 sub) />
[1, 0]                       <tspan (1 sub) />

Definition at line 62 of file svgfig.py.

Constructor & Destructor Documentation

def svgfig.SVG.__init__ (   self,
  t_sub,
  attr 
)

Definition at line 123 of file svgfig.py.

123  def __init__(self, *t_sub, **attr):
124  if len(t_sub) == 0: raise TypeError("SVG element must have a t (SVG type)")
125 
126  # first argument is t (SVG type)
127  self.t = t_sub[0]
128  # the rest are sub-elements
129  self.sub = list(t_sub[1:])
130 
131  # keyword arguments are attributes
132  # need to preprocess to handle differences between SVG and Python syntax
133  self.attr = attr_preprocess(attr)
134 
def attr_preprocess(attr)
Definition: svgfig.py:46
def __init__(self, t_sub, attr)
Definition: svgfig.py:123
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run

Member Function Documentation

def svgfig.SVG.__contains__ (   self,
  value 
)
x in svg == True iff x is an attribute in svg.

Definition at line 168 of file svgfig.py.

References svgfig.SVG.attr.

168  def __contains__(self, value):
169  """x in svg == True iff x is an attribute in svg."""
170  return value in self.attr
171 
def __contains__(self, value)
Definition: svgfig.py:168
def svgfig.SVG.__delitem__ (   self,
  ti 
)
Index is a list that descends tree, returning a sub-element if
it ends with a number and an attribute if it ends with a string.

Definition at line 157 of file svgfig.py.

157  def __delitem__(self, ti):
158  """Index is a list that descends tree, returning a sub-element if
159  it ends with a number and an attribute if it ends with a string."""
160  obj = self
161  if isinstance(ti, (list, tuple)):
162  for i in ti[:-1]: obj = obj[i]
163  ti = ti[-1]
164 
165  if isinstance(ti, (int, long, slice)): del obj.sub[ti]
166  else: del obj.attr[ti]
167 
def __delitem__(self, ti)
Definition: svgfig.py:157
def svgfig.SVG.__eq__ (   self,
  other 
)
x == y iff x represents the same SVG as y.

Definition at line 172 of file svgfig.py.

References svgfig.SVG.attr, triggerObjects_cff.id, svgfig.SVG.sub, AlignmentMonitorMuonSystemMap1D::MyCSCDetId.t, and svgfig.SVG.t.

Referenced by SequenceTypes._UnarySequenceOperator.__ne__().

172  def __eq__(self, other):
173  """x == y iff x represents the same SVG as y."""
174  if id(self) == id(other): return True
175  return isinstance(other, SVG) and self.t == other.t and self.sub == other.sub and self.attr == other.attr
176 
def __eq__(self, other)
Definition: svgfig.py:172
def svgfig.SVG.__getitem__ (   self,
  ti 
)
Index is a list that descends tree, returning a sub-element if
it ends with a number and an attribute if it ends with a string.

Definition at line 135 of file svgfig.py.

135  def __getitem__(self, ti):
136  """Index is a list that descends tree, returning a sub-element if
137  it ends with a number and an attribute if it ends with a string."""
138  obj = self
139  if isinstance(ti, (list, tuple)):
140  for i in ti[:-1]: obj = obj[i]
141  ti = ti[-1]
142 
143  if isinstance(ti, (int, long, slice)): return obj.sub[ti]
144  else: return obj.attr[ti]
145 
def __getitem__(self, ti)
Definition: svgfig.py:135
def svgfig.SVG.__iter__ (   self)

Definition at line 246 of file svgfig.py.

References svgfig.SVG.depth_first().

246  def __iter__(self): return self.depth_first()
247 
def depth_first(self, depth_limit=None)
end nested class
Definition: svgfig.py:234
def __iter__(self)
Definition: svgfig.py:246
def svgfig.SVG.__ne__ (   self,
  other 
)
x != y iff x does not represent the same SVG as y.

Definition at line 177 of file svgfig.py.

177  def __ne__(self, other):
178  """x != y iff x does not represent the same SVG as y."""
179  return not (self == other)
180 
def __ne__(self, other)
Definition: svgfig.py:177
def svgfig.SVG.__repr__ (   self)

Definition at line 284 of file svgfig.py.

References svgfig.SVG.xml().

Referenced by data_sources.json_file.__str__().

284  def __repr__(self): return self.xml(depth_limit=0)
285 
def __repr__(self)
Definition: svgfig.py:284
def xml(self, indent=" ", newl="\n", depth_limit=None, depth=0)
Definition: svgfig.py:319
def svgfig.SVG.__setitem__ (   self,
  ti,
  value 
)
Index is a list that descends tree, returning a sub-element if
it ends with a number and an attribute if it ends with a string.

Definition at line 146 of file svgfig.py.

146  def __setitem__(self, ti, value):
147  """Index is a list that descends tree, returning a sub-element if
148  it ends with a number and an attribute if it ends with a string."""
149  obj = self
150  if isinstance(ti, (list, tuple)):
151  for i in ti[:-1]: obj = obj[i]
152  ti = ti[-1]
153 
154  if isinstance(ti, (int, long, slice)): obj.sub[ti] = value
155  else: obj.attr[ti] = value
156 
def __setitem__(self, ti, value)
Definition: svgfig.py:146
def svgfig.SVG.__standalone_xml (   self,
  indent,
  newl 
)
private

Definition at line 372 of file svgfig.py.

References join(), svgfig.SVG.sub, AlignmentMonitorMuonSystemMap1D::MyCSCDetId.t, and svgfig.SVG.t.

372  def __standalone_xml(self, indent, newl):
373  output = [u"<%s" % self.t]
374 
375  for n, v in self.attr.items():
376  if isinstance(v, dict):
377  v = "; ".join(["%s:%s" % (ni, vi) for ni, vi in v.items()])
378  elif isinstance(v, (list, tuple)):
379  v = ", ".join(v)
380  output.append(u" %s=\"%s\"" % (n, v))
381 
382  if len(self.sub) == 0:
383  output.append(u" />%s%s" % (newl, newl))
384  return output
385 
386  elif self.t == "text" or self.t == "tspan" or self.t == "style":
387  output.append(u">")
388 
389  else:
390  output.append(u">%s%s" % (newl, newl))
391 
392  for s in self.sub:
393  if isinstance(s, SVG): output.extend(s.__standalone_xml(indent, newl))
394  else: output.append(unicode(s))
395 
396  if self.t == "tspan": output.append(u"</%s>" % self.t)
397  else: output.append(u"</%s>%s%s" % (self.t, newl, newl))
398 
399  return output
400 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def __standalone_xml(self, indent, newl)
Definition: svgfig.py:372
def svgfig.SVG.__str__ (   self)
def svgfig.SVG.append (   self,
  x 
)
Appends x to the list of sub-elements (drawn last, overlaps
other primatives).

Definition at line 181 of file svgfig.py.

Referenced by diclist.diclist.add(), Vispa.Views.PropertyView.PropertyView.addProperty(), and BeautifulSoup.Tag.setString().

181  def append(self, x):
182  """Appends x to the list of sub-elements (drawn last, overlaps
183  other primatives)."""
184  self.sub.append(x)
185 
def append(self, x)
Definition: svgfig.py:181
def svgfig.SVG.breadth_first (   self,
  depth_limit = None 
)
Not implemented yet.  Any ideas on how to do it?

Returns a breadth-first generator over the SVG.  If depth_limit
is a number, stop recursion at that depth.

Definition at line 239 of file svgfig.py.

239  def breadth_first(self, depth_limit=None):
240  """Not implemented yet. Any ideas on how to do it?
241 
242  Returns a breadth-first generator over the SVG. If depth_limit
243  is a number, stop recursion at that depth."""
244  raise NotImplementedError("Got an algorithm for breadth-first searching a tree without effectively copying the tree?")
245 
def breadth_first(self, depth_limit=None)
Definition: svgfig.py:239
def svgfig.SVG.clone (   self,
  shallow = False 
)
Deep copy of SVG tree.  Set shallow=True for a shallow copy.

Definition at line 195 of file svgfig.py.

195  def clone(self, shallow=False):
196  """Deep copy of SVG tree. Set shallow=True for a shallow copy."""
197  if shallow:
198  return copy.copy(self)
199  else:
200  return copy.deepcopy(self)
201 
def clone(self, shallow=False)
Definition: svgfig.py:195
def svgfig.SVG.depth_first (   self,
  depth_limit = None 
)

end nested class

Returns a depth-first generator over the SVG.  If depth_limit
is a number, stop recursion at that depth.

Definition at line 234 of file svgfig.py.

Referenced by svgfig.SVG.__iter__(), and svgfig.SVG.tree().

234  def depth_first(self, depth_limit=None):
235  """Returns a depth-first generator over the SVG. If depth_limit
236  is a number, stop recursion at that depth."""
237  return self.SVGDepthIterator(self, (), depth_limit)
238 
def depth_first(self, depth_limit=None)
end nested class
Definition: svgfig.py:234
def svgfig.SVG.extend (   self,
  x 
)
Extends list of sub-elements by a list x.

Definition at line 191 of file svgfig.py.

Referenced by MatrixUtil.WF.__init__(), Config.Process.extend(), Config.Process.load(), and Mixins._ValidatingParameterListBase.setValue().

191  def extend(self, x):
192  """Extends list of sub-elements by a list x."""
193  self.sub.extend(x)
194 
def extend(self, x)
Definition: svgfig.py:191
def svgfig.SVG.firefox (   self,
  fileName = None,
  encoding = "utf-8" 
)
View in "firefox", assuming that program is available on your system.

fileName        default=None            note that any file named _default_fileName will be
                                    overwritten if no fileName is specified. If the extension
                                    is ".svgz" or ".gz", the output will be gzipped
encoding        default="utf-8"       file encoding (default is Unicode)

Definition at line 461 of file svgfig.py.

References svgfig.SVG.interpret_fileName(), and svgfig.SVG.save().

461  def firefox(self, fileName=None, encoding="utf-8"):
462  """View in "firefox", assuming that program is available on your system.
463 
464  fileName default=None note that any file named _default_fileName will be
465  overwritten if no fileName is specified. If the extension
466  is ".svgz" or ".gz", the output will be gzipped
467  encoding default="utf-8" file encoding (default is Unicode)
468  """
469  fileName = self.interpret_fileName(fileName)
470  self.save(fileName, encoding)
471  os.spawnvp(os.P_NOWAIT, "firefox", ("firefox", fileName))
472 
def save(self, fileName=None, encoding="utf-8", compresslevel=None)
Definition: svgfig.py:408
def firefox(self, fileName=None, encoding="utf-8")
Definition: svgfig.py:461
def interpret_fileName(self, fileName=None)
Definition: svgfig.py:401
def svgfig.SVG.inkscape (   self,
  fileName = None,
  encoding = "utf-8" 
)
View in "inkscape", assuming that program is available on your system.

fileName        default=None            note that any file named _default_fileName will be
                                    overwritten if no fileName is specified. If the extension
                                    is ".svgz" or ".gz", the output will be gzipped
encoding        default="utf-8"       file encoding (default is Unicode)

Definition at line 449 of file svgfig.py.

References svgfig.SVG.interpret_fileName(), and svgfig.SVG.save().

449  def inkscape(self, fileName=None, encoding="utf-8"):
450  """View in "inkscape", assuming that program is available on your system.
451 
452  fileName default=None note that any file named _default_fileName will be
453  overwritten if no fileName is specified. If the extension
454  is ".svgz" or ".gz", the output will be gzipped
455  encoding default="utf-8" file encoding (default is Unicode)
456  """
457  fileName = self.interpret_fileName(fileName)
458  self.save(fileName, encoding)
459  os.spawnvp(os.P_NOWAIT, "inkscape", ("inkscape", fileName))
460 
def inkscape(self, fileName=None, encoding="utf-8")
Definition: svgfig.py:449
def save(self, fileName=None, encoding="utf-8", compresslevel=None)
Definition: svgfig.py:408
def interpret_fileName(self, fileName=None)
Definition: svgfig.py:401
def svgfig.SVG.inkview (   self,
  fileName = None,
  encoding = "utf-8" 
)
View in "inkview", assuming that program is available on your system.

fileName        default=None            note that any file named _default_fileName will be
                                    overwritten if no fileName is specified. If the extension
                                    is ".svgz" or ".gz", the output will be gzipped
encoding        default="utf-8"       file encoding (default is Unicode)

Definition at line 437 of file svgfig.py.

References svgfig.SVG.interpret_fileName(), and svgfig.SVG.save().

437  def inkview(self, fileName=None, encoding="utf-8"):
438  """View in "inkview", assuming that program is available on your system.
439 
440  fileName default=None note that any file named _default_fileName will be
441  overwritten if no fileName is specified. If the extension
442  is ".svgz" or ".gz", the output will be gzipped
443  encoding default="utf-8" file encoding (default is Unicode)
444  """
445  fileName = self.interpret_fileName(fileName)
446  self.save(fileName, encoding)
447  os.spawnvp(os.P_NOWAIT, "inkview", ("inkview", fileName))
448 
def save(self, fileName=None, encoding="utf-8", compresslevel=None)
Definition: svgfig.py:408
def inkview(self, fileName=None, encoding="utf-8")
Definition: svgfig.py:437
def interpret_fileName(self, fileName=None)
Definition: svgfig.py:401
def svgfig.SVG.interpret_fileName (   self,
  fileName = None 
)

Definition at line 401 of file svgfig.py.

Referenced by svgfig.SVG.firefox(), svgfig.SVG.inkscape(), svgfig.SVG.inkview(), and svgfig.SVG.save().

401  def interpret_fileName(self, fileName=None):
402  if fileName == None:
403  fileName = _default_fileName
404  if re.search("windows", platform.system(), re.I) and not os.path.isabs(fileName):
405  fileName = _default_directory + os.sep + fileName
406  return fileName
407 
def interpret_fileName(self, fileName=None)
Definition: svgfig.py:401
def svgfig.SVG.items (   self,
  sub = True,
  attr = True,
  text = True 
)
Get a recursively-generated list of tree-index, sub-element/attribute pairs.

If sub == False, do not show sub-elements.
If attr == False, do not show attributes.
If text == False, do not show text/Unicode sub-elements.

Definition at line 248 of file svgfig.py.

Referenced by betterConfigParser.BetterConfigParser.exists(), svgfig.SVG.keys(), python.rootplot.core.Options.kwarg_list(), and svgfig.SVG.values().

248  def items(self, sub=True, attr=True, text=True):
249  """Get a recursively-generated list of tree-index, sub-element/attribute pairs.
250 
251  If sub == False, do not show sub-elements.
252  If attr == False, do not show attributes.
253  If text == False, do not show text/Unicode sub-elements.
254  """
255  output = []
256  for ti, s in self:
257  show = False
258  if isinstance(ti[-1], (int, long)):
259  if isinstance(s, basestring): show = text
260  else: show = sub
261  else: show = attr
262 
263  if show: output.append((ti, s))
264  return output
265 
def items(self, sub=True, attr=True, text=True)
Definition: svgfig.py:248
def svgfig.SVG.keys (   self,
  sub = True,
  attr = True,
  text = True 
)
Get a recursively-generated list of tree-indexes.

If sub == False, do not show sub-elements.
If attr == False, do not show attributes.
If text == False, do not show text/Unicode sub-elements.

Definition at line 266 of file svgfig.py.

References PixelDCSObject< T >.items, tensorflow::TBBSession::ExecutorsAndKeys.items, tensorflow::NTSession::ExecutorsAndKeys.items, argparse.HelpFormatter._Section.items, python.rootplot.argparse.HelpFormatter._Section.items, and svgfig.SVG.items().

Referenced by psClasses.queueList.__init__(), psClasses.queueList.smallestQueue(), and psClasses.queueList.thinerQueue().

266  def keys(self, sub=True, attr=True, text=True):
267  """Get a recursively-generated list of tree-indexes.
268 
269  If sub == False, do not show sub-elements.
270  If attr == False, do not show attributes.
271  If text == False, do not show text/Unicode sub-elements.
272  """
273  return [ti for ti, s in self.items(sub, attr, text)]
274 
def keys(self, sub=True, attr=True, text=True)
Definition: svgfig.py:266
def items(self, sub=True, attr=True, text=True)
Definition: svgfig.py:248
def svgfig.SVG.prepend (   self,
  x 
)
Prepends x to the list of sub-elements (drawn first may be
overlapped by other primatives).

Definition at line 186 of file svgfig.py.

References svgfig.SVG.sub.

186  def prepend(self, x):
187  """Prepends x to the list of sub-elements (drawn first may be
188  overlapped by other primatives)."""
189  self.sub[0:0] = [x]
190 
def prepend(self, x)
Definition: svgfig.py:186
def svgfig.SVG.save (   self,
  fileName = None,
  encoding = "utf-8",
  compresslevel = None 
)
Save to a file for viewing.  Note that svg.save() overwrites the file named _default_fileName.

fileName        default=None            note that _default_fileName will be overwritten if
                                    no fileName is specified. If the extension
                                    is ".svgz" or ".gz", the output will be gzipped
encoding        default="utf-8"       file encoding (default is Unicode)
compresslevel   default=None            if a number, the output will be gzipped with that
                                    compression level (1-9, 1 being fastest and 9 most
                                    thorough)

Definition at line 408 of file svgfig.py.

References svgfig.SVG.interpret_fileName(), and svgfig.SVG.standalone_xml().

Referenced by Vispa.Main.TabController.TabController.allowClose(), Vispa.Main.TabController.TabController.checkModificationTimestamp(), svgfig.SVG.firefox(), svgfig.SVG.inkscape(), svgfig.SVG.inkview(), and SpecificationBuilder_cfi.Specification.saveAll().

408  def save(self, fileName=None, encoding="utf-8", compresslevel=None):
409  """Save to a file for viewing. Note that svg.save() overwrites the file named _default_fileName.
410 
411  fileName default=None note that _default_fileName will be overwritten if
412  no fileName is specified. If the extension
413  is ".svgz" or ".gz", the output will be gzipped
414  encoding default="utf-8" file encoding (default is Unicode)
415  compresslevel default=None if a number, the output will be gzipped with that
416  compression level (1-9, 1 being fastest and 9 most
417  thorough)
418  """
419  fileName = self.interpret_fileName(fileName)
420 
421  if compresslevel != None or re.search("\.svgz$", fileName, re.I) or re.search("\.gz$", fileName, re.I):
422  import gzip
423  if compresslevel == None:
424  f = gzip.GzipFile(fileName, "w")
425  else:
426  f = gzip.GzipFile(fileName, "w", compresslevel)
427 
428  f = codecs.EncodedFile(f, "utf-8", encoding)
429  f.write(self.standalone_xml())
430  f.close()
431 
432  else:
433  f = codecs.open(fileName, "w", encoding=encoding)
434  f.write(self.standalone_xml())
435  f.close()
436 
def save(self, fileName=None, encoding="utf-8", compresslevel=None)
Definition: svgfig.py:408
def standalone_xml(self, indent=" ", newl="\n")
Definition: svgfig.py:357
def interpret_fileName(self, fileName=None)
Definition: svgfig.py:401
def svgfig.SVG.standalone_xml (   self,
  indent = "    ",
  newl = "\n" 
)
Get an XML representation of the SVG that can be saved/rendered.

indent      string used for indenting
newl        string used for newlines

Definition at line 357 of file svgfig.py.

References svgfig.canvas(), join(), AlignmentMonitorMuonSystemMap1D::MyCSCDetId.t, and svgfig.SVG.t.

Referenced by svgfig.SVG.save().

357  def standalone_xml(self, indent=" ", newl="\n"):
358  """Get an XML representation of the SVG that can be saved/rendered.
359 
360  indent string used for indenting
361  newl string used for newlines
362  """
363 
364  if self.t == "svg": top = self
365  else: top = canvas(self)
366  return """\
367 <?xml version="1.0" standalone="no"?>
368 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
369 
370 """ + ("".join(top.__standalone_xml(indent, newl))) # end of return statement
371 
def standalone_xml(self, indent=" ", newl="\n")
Definition: svgfig.py:357
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def canvas(sub, attr)
Definition: svgfig.py:481
def svgfig.SVG.tree (   self,
  depth_limit = None,
  sub = True,
  attr = True,
  text = True,
  tree_width = 20,
  obj_width = 80 
)
Print (actually, return a string of) the tree in a form useful for browsing.

If depth_limit == a number, stop recursion at that depth.
If sub == False, do not show sub-elements.
If attr == False, do not show attributes.
If text == False, do not show text/Unicode sub-elements.
tree_width is the number of characters reserved for printing tree indexes.
obj_width is the number of characters reserved for printing sub-elements/attributes.

Definition at line 290 of file svgfig.py.

References svgfig.SVG.depth_first(), join(), and list().

Referenced by svgfig.SVG.__str__(), ZJetsTreeAnalyzer.ZJetsTreeAnalyzer.beginLoop(), MetTreeProducer.MetTreeProducer.declareVariables(), core.AutoFillTreeProducer.AutoFillTreeProducer.declareVariables(), core.AutoFillTreeProducer.AutoFillTreeProducer.fillTree(), ZJetsTreeAnalyzer.ZJetsTreeAnalyzer.process(), MetTreeProducer.MetTreeProducer.process(), and python.cmstools.EventTree.SetAlias().

290  def tree(self, depth_limit=None, sub=True, attr=True, text=True, tree_width=20, obj_width=80):
291  """Print (actually, return a string of) the tree in a form useful for browsing.
292 
293  If depth_limit == a number, stop recursion at that depth.
294  If sub == False, do not show sub-elements.
295  If attr == False, do not show attributes.
296  If text == False, do not show text/Unicode sub-elements.
297  tree_width is the number of characters reserved for printing tree indexes.
298  obj_width is the number of characters reserved for printing sub-elements/attributes.
299  """
300 
301  output = []
302 
303  line = "%s %s" % (("%%-%ds" % tree_width) % repr(None), ("%%-%ds" % obj_width) % (repr(self))[0:obj_width])
304  output.append(line)
305 
306  for ti, s in self.depth_first(depth_limit):
307  show = False
308  if isinstance(ti[-1], (int, long)):
309  if isinstance(s, basestring): show = text
310  else: show = sub
311  else: show = attr
312 
313  if show:
314  line = "%s %s" % (("%%-%ds" % tree_width) % repr(list(ti)), ("%%-%ds" % obj_width) % (" "*len(ti) + repr(s))[0:obj_width])
315  output.append(line)
316 
317  return "\n".join(output)
318 
def depth_first(self, depth_limit=None)
end nested class
Definition: svgfig.py:234
def tree(self, depth_limit=None, sub=True, attr=True, text=True, tree_width=20, obj_width=80)
Definition: svgfig.py:290
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
def svgfig.SVG.values (   self,
  sub = True,
  attr = True,
  text = True 
)
Get a recursively-generated list of sub-elements and attributes.

If sub == False, do not show sub-elements.
If attr == False, do not show attributes.
If text == False, do not show text/Unicode sub-elements.

Definition at line 275 of file svgfig.py.

References PixelDCSObject< T >.items, tensorflow::TBBSession::ExecutorsAndKeys.items, tensorflow::NTSession::ExecutorsAndKeys.items, argparse.HelpFormatter._Section.items, python.rootplot.argparse.HelpFormatter._Section.items, and svgfig.SVG.items().

Referenced by genericValidation.ValidationWithPlotsSummaryBase.SummaryItem.value().

275  def values(self, sub=True, attr=True, text=True):
276  """Get a recursively-generated list of sub-elements and attributes.
277 
278  If sub == False, do not show sub-elements.
279  If attr == False, do not show attributes.
280  If text == False, do not show text/Unicode sub-elements.
281  """
282  return [s for ti, s in self.items(sub, attr, text)]
283 
def values(self, sub=True, attr=True, text=True)
Definition: svgfig.py:275
def items(self, sub=True, attr=True, text=True)
Definition: svgfig.py:248
def svgfig.SVG.xml (   self,
  indent = "    ",
  newl = "\n",
  depth_limit = None,
  depth = 0 
)
Get an XML representation of the SVG.

indent      string used for indenting
newl        string used for newlines
If depth_limit == a number, stop recursion at that depth.
depth       starting depth (not useful for users)

print svg.xml()

Definition at line 319 of file svgfig.py.

References join(), svgfig.SVG.sub, AlignmentMonitorMuonSystemMap1D::MyCSCDetId.t, and svgfig.SVG.t.

Referenced by svgfig.SVG.__repr__().

319  def xml(self, indent=" ", newl="\n", depth_limit=None, depth=0):
320  """Get an XML representation of the SVG.
321 
322  indent string used for indenting
323  newl string used for newlines
324  If depth_limit == a number, stop recursion at that depth.
325  depth starting depth (not useful for users)
326 
327  print svg.xml()
328  """
329 
330  attrstr = []
331  for n, v in self.attr.items():
332  if isinstance(v, dict):
333  v = "; ".join(["%s:%s" % (ni, vi) for ni, vi in v.items()])
334  elif isinstance(v, (list, tuple)):
335  v = ", ".join(v)
336  attrstr.append(" %s=%s" % (n, repr(v)))
337  attrstr = "".join(attrstr)
338 
339  if len(self.sub) == 0: return "%s<%s%s />" % (indent * depth, self.t, attrstr)
340 
341  if depth_limit == None or depth_limit > depth:
342  substr = []
343  for s in self.sub:
344  if isinstance(s, SVG):
345  substr.append(s.xml(indent, newl, depth_limit, depth + 1) + newl)
346  elif isinstance(s, str):
347  substr.append("%s%s%s" % (indent * (depth + 1), s, newl))
348  else:
349  substr.append("%s%s%s" % (indent * (depth + 1), repr(s), newl))
350  substr = "".join(substr)
351 
352  return "%s<%s%s>%s%s%s</%s>" % (indent * depth, self.t, attrstr, newl, substr, indent * depth, self.t)
353 
354  else:
355  return "%s<%s (%d sub)%s />" % (indent * depth, self.t, len(self.sub), attrstr)
356 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def xml(self, indent=" ", newl="\n", depth_limit=None, depth=0)
Definition: svgfig.py:319

Member Data Documentation

svgfig.SVG.attr
svgfig.SVG.sub
svgfig.SVG.t