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 63 of file svgfig.py.

Constructor & Destructor Documentation

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

Definition at line 124 of file svgfig.py.

124  def __init__(self, *t_sub, **attr):
125  if len(t_sub) == 0: raise TypeError("SVG element must have a t (SVG type)")
126 
127  # first argument is t (SVG type)
128  self.t = t_sub[0]
129  # the rest are sub-elements
130  self.sub = list(t_sub[1:])
131 
132  # keyword arguments are attributes
133  # need to preprocess to handle differences between SVG and Python syntax
134  self.attr = attr_preprocess(attr)
135 
def attr_preprocess(attr)
Definition: svgfig.py:47
def __init__(self, t_sub, attr)
Definition: svgfig.py:124
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 169 of file svgfig.py.

References svgfig.SVG.attr.

169  def __contains__(self, value):
170  """x in svg == True iff x is an attribute in svg."""
171  return value in self.attr
172 
def __contains__(self, value)
Definition: svgfig.py:169
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 158 of file svgfig.py.

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

Definition at line 173 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__().

173  def __eq__(self, other):
174  """x == y iff x represents the same SVG as y."""
175  if id(self) == id(other): return True
176  return isinstance(other, SVG) and self.t == other.t and self.sub == other.sub and self.attr == other.attr
177 
def __eq__(self, other)
Definition: svgfig.py:173
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 136 of file svgfig.py.

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

Definition at line 247 of file svgfig.py.

References svgfig.SVG.depth_first().

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

Definition at line 178 of file svgfig.py.

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

Definition at line 285 of file svgfig.py.

References svgfig.SVG.xml().

Referenced by data_sources.json_file.__str__().

285  def __repr__(self): return self.xml(depth_limit=0)
286 
def __repr__(self)
Definition: svgfig.py:285
def xml(self, indent=" ", newl="\n", depth_limit=None, depth=0)
Definition: svgfig.py:320
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 147 of file svgfig.py.

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

Definition at line 373 of file svgfig.py.

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

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

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

182  def append(self, x):
183  """Appends x to the list of sub-elements (drawn last, overlaps
184  other primatives)."""
185  self.sub.append(x)
186 
def append(self, x)
Definition: svgfig.py:182
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 240 of file svgfig.py.

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

Definition at line 196 of file svgfig.py.

196  def clone(self, shallow=False):
197  """Deep copy of SVG tree. Set shallow=True for a shallow copy."""
198  if shallow:
199  return copy.copy(self)
200  else:
201  return copy.deepcopy(self)
202 
def clone(self, shallow=False)
Definition: svgfig.py:196
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 235 of file svgfig.py.

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

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

Definition at line 192 of file svgfig.py.

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

192  def extend(self, x):
193  """Extends list of sub-elements by a list x."""
194  self.sub.extend(x)
195 
def extend(self, x)
Definition: svgfig.py:192
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 462 of file svgfig.py.

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

462  def firefox(self, fileName=None, encoding="utf-8"):
463  """View in "firefox", assuming that program is available on your system.
464 
465  fileName default=None note that any file named _default_fileName will be
466  overwritten if no fileName is specified. If the extension
467  is ".svgz" or ".gz", the output will be gzipped
468  encoding default="utf-8" file encoding (default is Unicode)
469  """
470  fileName = self.interpret_fileName(fileName)
471  self.save(fileName, encoding)
472  os.spawnvp(os.P_NOWAIT, "firefox", ("firefox", fileName))
473 
def save(self, fileName=None, encoding="utf-8", compresslevel=None)
Definition: svgfig.py:409
def firefox(self, fileName=None, encoding="utf-8")
Definition: svgfig.py:462
def interpret_fileName(self, fileName=None)
Definition: svgfig.py:402
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 450 of file svgfig.py.

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

450  def inkscape(self, fileName=None, encoding="utf-8"):
451  """View in "inkscape", assuming that program is available on your system.
452 
453  fileName default=None note that any file named _default_fileName will be
454  overwritten if no fileName is specified. If the extension
455  is ".svgz" or ".gz", the output will be gzipped
456  encoding default="utf-8" file encoding (default is Unicode)
457  """
458  fileName = self.interpret_fileName(fileName)
459  self.save(fileName, encoding)
460  os.spawnvp(os.P_NOWAIT, "inkscape", ("inkscape", fileName))
461 
def inkscape(self, fileName=None, encoding="utf-8")
Definition: svgfig.py:450
def save(self, fileName=None, encoding="utf-8", compresslevel=None)
Definition: svgfig.py:409
def interpret_fileName(self, fileName=None)
Definition: svgfig.py:402
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 438 of file svgfig.py.

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

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

Definition at line 402 of file svgfig.py.

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

402  def interpret_fileName(self, fileName=None):
403  if fileName == None:
404  fileName = _default_fileName
405  if re.search("windows", platform.system(), re.I) and not os.path.isabs(fileName):
406  fileName = _default_directory + os.sep + fileName
407  return fileName
408 
def interpret_fileName(self, fileName=None)
Definition: svgfig.py:402
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 249 of file svgfig.py.

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

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

References PixelDCSObject< T >.items, tensorflow::NTSession::ExecutorsAndKeys.items, tensorflow::TBBSession::ExecutorsAndKeys.items, and svgfig.SVG.items().

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

267  def keys(self, sub=True, attr=True, text=True):
268  """Get a recursively-generated list of tree-indexes.
269 
270  If sub == False, do not show sub-elements.
271  If attr == False, do not show attributes.
272  If text == False, do not show text/Unicode sub-elements.
273  """
274  return [ti for ti, s in self.items(sub, attr, text)]
275 
def keys(self, sub=True, attr=True, text=True)
Definition: svgfig.py:267
def items(self, sub=True, attr=True, text=True)
Definition: svgfig.py:249
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 187 of file svgfig.py.

References svgfig.SVG.sub.

187  def prepend(self, x):
188  """Prepends x to the list of sub-elements (drawn first may be
189  overlapped by other primatives)."""
190  self.sub[0:0] = [x]
191 
def prepend(self, x)
Definition: svgfig.py:187
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 409 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().

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

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

Referenced by svgfig.SVG.save().

358  def standalone_xml(self, indent=" ", newl="\n"):
359  """Get an XML representation of the SVG that can be saved/rendered.
360 
361  indent string used for indenting
362  newl string used for newlines
363  """
364 
365  if self.t == "svg": top = self
366  else: top = canvas(self)
367  return """\
368 <?xml version="1.0" standalone="no"?>
369 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
370 
371 """ + ("".join(top.__standalone_xml(indent, newl))) # end of return statement
372 
def standalone_xml(self, indent=" ", newl="\n")
Definition: svgfig.py:358
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def canvas(sub, attr)
Definition: svgfig.py:482
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 291 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().

291  def tree(self, depth_limit=None, sub=True, attr=True, text=True, tree_width=20, obj_width=80):
292  """Print (actually, return a string of) the tree in a form useful for browsing.
293 
294  If depth_limit == a number, stop recursion at that depth.
295  If sub == False, do not show sub-elements.
296  If attr == False, do not show attributes.
297  If text == False, do not show text/Unicode sub-elements.
298  tree_width is the number of characters reserved for printing tree indexes.
299  obj_width is the number of characters reserved for printing sub-elements/attributes.
300  """
301 
302  output = []
303 
304  line = "%s %s" % (("%%-%ds" % tree_width) % repr(None), ("%%-%ds" % obj_width) % (repr(self))[0:obj_width])
305  output.append(line)
306 
307  for ti, s in self.depth_first(depth_limit):
308  show = False
309  if isinstance(ti[-1], (int, long)):
310  if isinstance(s, str): show = text
311  else: show = sub
312  else: show = attr
313 
314  if show:
315  line = "%s %s" % (("%%-%ds" % tree_width) % repr(list(ti)), ("%%-%ds" % obj_width) % (" "*len(ti) + repr(s))[0:obj_width])
316  output.append(line)
317 
318  return "\n".join(output)
319 
def depth_first(self, depth_limit=None)
end nested class
Definition: svgfig.py:235
def tree(self, depth_limit=None, sub=True, attr=True, text=True, tree_width=20, obj_width=80)
Definition: svgfig.py:291
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 276 of file svgfig.py.

References PixelDCSObject< T >.items, tensorflow::NTSession::ExecutorsAndKeys.items, tensorflow::TBBSession::ExecutorsAndKeys.items, and svgfig.SVG.items().

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

276  def values(self, sub=True, attr=True, text=True):
277  """Get a recursively-generated list of sub-elements and attributes.
278 
279  If sub == False, do not show sub-elements.
280  If attr == False, do not show attributes.
281  If text == False, do not show text/Unicode sub-elements.
282  """
283  return [s for ti, s in self.items(sub, attr, text)]
284 
def values(self, sub=True, attr=True, text=True)
Definition: svgfig.py:276
def items(self, sub=True, attr=True, text=True)
Definition: svgfig.py:249
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 320 of file svgfig.py.

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

Referenced by svgfig.SVG.__repr__().

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

Member Data Documentation

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