CMS 3D CMS Logo

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

nested class More...

Public Member Functions

def __init__ (self, svg, ti, depth_limit)
 
def __iter__ (self)
 
def next (self)
 

Public Attributes

 depth_limit
 
 iterators
 
 shown
 
 svg
 
 ti
 

Detailed Description

nested class

Manages SVG iteration.

Definition at line 204 of file svgfig.py.

Constructor & Destructor Documentation

def svgfig.SVG.SVGDepthIterator.__init__ (   self,
  svg,
  ti,
  depth_limit 
)

Definition at line 207 of file svgfig.py.

207  def __init__(self, svg, ti, depth_limit):
208  self.svg = svg
209  self.ti = ti
210  self.shown = False
211  self.depth_limit = depth_limit
212 
def __init__(self, svg, ti, depth_limit)
Definition: svgfig.py:207

Member Function Documentation

def svgfig.SVG.SVGDepthIterator.__iter__ (   self)

Definition at line 213 of file svgfig.py.

213  def __iter__(self): return self
214 
def svgfig.SVG.SVGDepthIterator.next (   self)

Definition at line 215 of file svgfig.py.

References svgfig.SVG.SVGDepthIterator.depth_limit, svgfig.SVG.SVGDepthIterator.shown, svgfig.SVG.SVGDepthIterator.svg, and svgfig.SVG.SVGDepthIterator.ti.

215  def next(self):
216  if not self.shown:
217  self.shown = True
218  if self.ti != ():
219  return self.ti, self.svg
220 
221  if not isinstance(self.svg, SVG): raise StopIteration
222  if self.depth_limit != None and len(self.ti) >= self.depth_limit: raise StopIteration
223 
224  if "iterators" not in self.__dict__:
225  self.iterators = []
226  for i, s in enumerate(self.svg.sub):
227  self.iterators.append(self.__class__(s, self.ti + (i,), self.depth_limit))
228  for k, s in self.svg.attr.items():
229  self.iterators.append(self.__class__(s, self.ti + (k,), self.depth_limit))
230  self.iterators = itertools.chain(*self.iterators)
231 
232  return next(self.iterators)
233  ### end nested class

Member Data Documentation

svgfig.SVG.SVGDepthIterator.depth_limit

Definition at line 211 of file svgfig.py.

Referenced by svgfig.SVG.SVGDepthIterator.next().

svgfig.SVG.SVGDepthIterator.iterators

Definition at line 225 of file svgfig.py.

svgfig.SVG.SVGDepthIterator.shown

Definition at line 210 of file svgfig.py.

Referenced by svgfig.SVG.SVGDepthIterator.next().

svgfig.SVG.SVGDepthIterator.svg

Definition at line 208 of file svgfig.py.

Referenced by svgfig.SVG.SVGDepthIterator.next().

svgfig.SVG.SVGDepthIterator.ti

Definition at line 209 of file svgfig.py.

Referenced by svgfig.SVG.SVGDepthIterator.next().