CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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__
 
def __delitem__
 
def __eq__
 
def __getitem__
 
def __init__
 
def __iter__
 
def __ne__
 
def __repr__
 
def __setitem__
 
def __str__
 
def append
 
def breadth_first
 
def clone
 
def depth_first
 end nested class More...
 
def extend
 
def firefox
 
def inkscape
 
def inkview
 
def interpret_fileName
 
def items
 
def keys
 
def prepend
 
def save
 
def standalone_xml
 
def tree
 
def values
 
def xml
 

Public Attributes

 attr
 
 sub
 
 t
 

Private Member Functions

def __standalone_xml
 

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.

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)
def __init__
Definition: svgfig.py:123
def attr_preprocess
Definition: svgfig.py:46
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.

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

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]
def __delitem__
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, ExpressReco_HICollisions_FallBack.id, svgfig.SVG.sub, 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
def __eq__
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.

Referenced by python.seqvaluedict.seqdict.slice().

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]
def __getitem__
Definition: svgfig.py:135
def svgfig.SVG.__iter__ (   self)

Definition at line 246 of file svgfig.py.

References svgfig.SVG.depth_first().

247  def __iter__(self): return self.depth_first()
def depth_first
end nested class
Definition: svgfig.py:234
def __iter__
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.

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

Definition at line 284 of file svgfig.py.

References svgfig.SVG.xml().

285  def __repr__(self): return self.xml(depth_limit=0)
def __repr__
Definition: svgfig.py:284
def xml
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.

Referenced by python.seqvaluedict.seqdict.update().

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
def __setitem__
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, 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
def __standalone_xml
Definition: svgfig.py:372
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def svgfig.SVG.__str__ (   self)
Print (actually, return a string of) the tree in a form useful for browsing.

Definition at line 286 of file svgfig.py.

References CSCTFAnalyzer.tree, CSCTFanalyzer.tree, NtupleROOTFile.tree, AlignmentIORootBase.tree, EcalPerEvtMatacqAnalyzer.tree, CheckSecondary.tree, ShallowTree.tree, KVFTest.tree, PhysicsTools::TreeReader.tree, cms::DiJetAnalyzer.tree, TreeSaver.tree, EcalMatacqAnalyzer.tree, JetTagMVAExtractor::Tree.tree, KinematicVertex.tree, KinematicParticle.tree, HcalIsoTrkAnalyzer.tree, IsolatedTracksHcalScale.tree, IsolatedTracksNxN.tree, and svgfig.SVG.tree().

287  def __str__(self):
288  """Print (actually, return a string of) the tree in a form useful for browsing."""
289  return self.tree(sub=True, attr=False, text=False)
def __str__
Definition: svgfig.py:286
def tree
Definition: svgfig.py:290
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 hltFindDuplicates.ModuleList.__init__(), python.Vispa.Views.PropertyView.PropertyView.addProperty(), hltFindDuplicates.ModuleList.extend(), and python.seqvaluedict.seqdict.push().

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)
def append
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.

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?"
def breadth_first
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.

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)
def clone
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().

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)
def depth_first
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 hltFindDuplicates.ModuleList.__init__(), 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)
def extend
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().

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))
def interpret_fileName
Definition: svgfig.py:401
def firefox
Definition: svgfig.py:461
def save
Definition: svgfig.py:408
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().

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))
def inkscape
Definition: svgfig.py:449
def interpret_fileName
Definition: svgfig.py:401
def save
Definition: svgfig.py:408
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().

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))
def interpret_fileName
Definition: svgfig.py:401
def inkview
Definition: svgfig.py:437
def save
Definition: svgfig.py:408
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().

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
def interpret_fileName
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 python.seqvaluedict.seqdict.__add__(), python.seqvaluedict.seqdict.__radd__(), validateAlignments.BetterConfigParser.exists(), svgfig.SVG.keys(), python.rootplot.core.Options.kwarg_list(), python.seqvaluedict.seqdict.map(), python.seqvaluedict.seqdict.reduce(), python.seqvaluedict.seqdict.swap(), 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, basestring): show = text
261  else: show = sub
262  else: show = attr
263 
264  if show: output.append((ti, s))
265  return output
def items
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 ora::RecordSpecImpl.items, PixelDCSObject< class >.items, HDQMInspector::DetIdItemList.items, argparse.HelpFormatter._Section.items, and svgfig.SVG.items().

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)]
def items
Definition: svgfig.py:248
def keys
Definition: svgfig.py:266
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.

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]
def prepend
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 python.Vispa.Main.TabController.TabController.allowClose(), python.Vispa.Main.TabController.TabController.checkModificationTimestamp(), svgfig.SVG.firefox(), svgfig.SVG.inkscape(), and svgfig.SVG.inkview().

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()
def interpret_fileName
Definition: svgfig.py:401
def save
Definition: svgfig.py:408
def standalone_xml
Definition: svgfig.py:357
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(), 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
def canvas
Definition: svgfig.py:481
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def standalone_xml
Definition: svgfig.py:357
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__(), 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, basestring): 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)
def depth_first
end nested class
Definition: svgfig.py:234
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def tree
Definition: svgfig.py:290
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 ora::RecordSpecImpl.items, PixelDCSObject< class >.items, HDQMInspector::DetIdItemList.items, argparse.HelpFormatter._Section.items, and svgfig.SVG.items().

Referenced by python.seqvaluedict.seqdict.items().

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)]
def items
Definition: svgfig.py:248
def values
Definition: svgfig.py:275
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, 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)
def xml
Definition: svgfig.py:319
static std::string join(char **cmd)
Definition: RemoteFile.cc:18

Member Data Documentation

svgfig.SVG.attr

Definition at line 133 of file svgfig.py.

Referenced by svgfig.SVG.__contains__(), svgfig.SVG.__eq__(), svgfig.Path.__repr__(), svgfig.Curve.__repr__(), svgfig.Poly.__repr__(), svgfig.Text.__repr__(), svgfig.TextGlobal.__repr__(), svgfig.Dots.__repr__(), svgfig.Line.__repr__(), svgfig.LineGlobal.__repr__(), svgfig.VLine.__repr__(), svgfig.HLine.__repr__(), svgfig.Rect.__repr__(), svgfig.Ellipse.__repr__(), svgfig.Ticks.__repr__(), svgfig.CurveAxis.__repr__(), svgfig.LineAxis.__repr__(), svgfig.XAxis.__repr__(), svgfig.YAxis.__repr__(), svgfig.Axes.__repr__(), svgfig.HGrid.__repr__(), svgfig.VGrid.__repr__(), svgfig.Grid.__repr__(), svgfig.Curve.Path(), svgfig.Poly.Path(), svgfig.Rect.Path(), svgfig.Path.SVG(), svgfig.Text.SVG(), svgfig.TextGlobal.SVG(), svgfig.LineGlobal.SVG(), svgfig.Axes.SVG(), svgfig.XErrorBars.SVG(), and svgfig.YErrorBars.SVG().

svgfig.SVG.sub

Definition at line 129 of file svgfig.py.

Referenced by svgfig.SVG.__eq__(), svgfig.SVG.__standalone_xml(), svgfig.SVG.prepend(), and svgfig.SVG.xml().

svgfig.SVG.t

Definition at line 127 of file svgfig.py.

Referenced by svgfig.SVG.__eq__(), svgfig.Curve.Sample.__repr__(), svgfig.SVG.__standalone_xml(), svgfig.SVG.standalone_xml(), and svgfig.SVG.xml().