lib/shapes/Shape.py
def svg(self):
		"""Returns the SVG representation as an XML fragment."""

		if isinstance(self.classes, basestring):
			classes = (self.classes,)
		else:
			classes = self.classes

		svgattrs = {}
		if self.id is not None:
			svgattrs["id"] = self.id
		if classes is not None:
			svgattrs["class"] = u' '.join(classes)
			
		for key in self.attrs.keys():
			try:
				# Attemt to format as float with given precision
				svgattrs[key] = u'{val:.{fp:d}f}'.format(fp=self.precision, val=self.attrs[key])
			except ValueError:
				# Now try the __str__
				svgattrs[key] = u'{val!s}'.format(val=self.attrs[key])
			except:
				raise

		svg = etree.Element(self.tag, svgattrs)
		if self.text is not None:
			svg.text = self.text

		if self.cdata is not None:
			# CDATA has to be added as a comment due to a
			# particularly dirty hack required by the output layer
			svg.append(etree.Comment(self.cdata))

		if type(self.subelements) == type(etree.Element('blank')):
			svg.append(self.subelements)
		elif self.subelements is not None:
			svg.extend(self.subelements)

		return svg
Returns the SVG representation as an XML fragment.
Returns the SVG representation as an XML fragment.
Returns the SVG representation as an XML fragment .
def svg(self):
		if isinstance(self.classes, basestring):
			classes = (self.classes,)
		else:
			classes = self.classes
		svgattrs = {}
		if self.id is not None:
			svgattrs["id"] = self.id
		if classes is not None:
			svgattrs["class"] = u' '.join(classes)
		for key in self.attrs.keys():
			try:
				svgattrs[key] = u'{val:.{fp:d}f}'.format(fp=self.precision, val=self.attrs[key])
			except ValueError:
				svgattrs[key] = u'{val!s}'.format(val=self.attrs[key])
			except:
				raise
		svg = etree.Element(self.tag, svgattrs)
		if self.text is not None:
			svg.text = self.text
		if self.cdata is not None:
			svg.append(etree.Comment(self.cdata))
		if type(self.subelements) == type(etree.Element('blank')):
			svg.append(self.subelements)
		elif self.subelements is not None:
			svg.extend(self.subelements)
		return svg
def svg ( self ) : if isinstance ( self . classes , basestring ) : classes = ( self . classes , ) else : classes = self . classes svgattrs = { } if self . id is not None : svgattrs [ "id" ] = self . id if classes is not None : svgattrs [ "class" ] = u' ' . join ( classes ) for key in self . attrs . keys ( ) : try : svgattrs [ key ] = u'{val:.{fp:d}f}' . format ( fp = self . precision , val = self . attrs [ key ] ) except ValueError : svgattrs [ key ] = u'{val!s}' . format ( val = self . attrs [ key ] ) except : raise svg = etree . Element ( self . tag , svgattrs ) if self . text is not None : svg . text = self . text if self . cdata is not None : svg . append ( etree . Comment ( self . cdata ) ) if type ( self . subelements ) == type ( etree . Element ( 'blank' ) ) : svg . append ( self . subelements ) elif self . subelements is not None : svg . extend ( self . subelements ) return svg
Returns the SVG representation as an XML fragment.
Returns the SVG representation as an XML fragment .
"""Returns the SVG representation as an XML fragment.""" # Attemt to format as float with given precision # Now try the __str__ # CDATA has to be added as a comment due to a # particularly dirty hack required by the output layer
self