svg/charts/graph.py
def start_svg(self):
		"Base SVG Document Creation"
		SVG_NAMESPACE = 'http://www.w3.org/2000/svg'
		SVG = '{%s}' % SVG_NAMESPACE
		NSMAP = {
			None: SVG_NAMESPACE,
			'xlink': 'http://www.w3.org/1999/xlink',
			'a3': 'http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/',
		}
		root_attrs = self._get_root_attributes()
		self.root = etree.Element(SVG + "svg", attrib=root_attrs, nsmap=NSMAP)
		if hasattr(self, 'style_sheet_href'):
			pi = etree.ProcessingInstruction(
				'xml-stylesheet',
				'href="%s" type="text/css"' % self.style_sheet_href
			)
			self.root.addprevious(pi)

		comment_strings = (
			' Created with SVG.Graph ',
			' SVG.Graph by Jason R. Coombs ',
			' Based on SVG::Graph by Sean E. Russel ',
			' Based on Perl SVG:TT:Graph by Leo Lapworth & Stephan Morgan ',
			' ' + '/' * 66,
		)
		list(map(self.root.append, map(etree.Comment, comment_strings)))

		defs = etree.SubElement(self.root, 'defs')
		self.add_defs(defs)

		if not hasattr(self, 'style_sheet_href') and not self.css_inline:
			self.root.append(etree.Comment(
				' include default stylesheet if none specified '))
			style = etree.SubElement(defs, 'style', type='text/css')
			# TODO: the text was previously escaped in a CDATA declaration... how
			#  to do that with etree?
			style.text = self.get_stylesheet().cssText

		self.root.append(etree.Comment('SVG Background'))
		etree.SubElement(self.root, 'rect', {
			'width': str(self.width),
			'height': str(self.height),
			'x': '0',
			'y': '0',
			'class': 'svgBackground'})
def start_svg(self):
		"Base SVG Document Creation"
		SVG_NAMESPACE = 'http://www.w3.org/2000/svg'
		SVG = '{%s}' % SVG_NAMESPACE
		NSMAP = {
			None: SVG_NAMESPACE,
			'xlink': 'http://www.w3.org/1999/xlink',
			'a3': 'http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/',
		}
		root_attrs = self._get_root_attributes()
		self.root = etree.Element(SVG + "svg", attrib=root_attrs, nsmap=NSMAP)
		if hasattr(self, 'style_sheet_href'):
			pi = etree.ProcessingInstruction(
				'xml-stylesheet',
				'href="%s" type="text/css"' % self.style_sheet_href
			)
			self.root.addprevious(pi)

		comment_strings = (
			' Created with SVG.Graph ',
			' SVG.Graph by Jason R. Coombs ',
			' Based on SVG::Graph by Sean E. Russel ',
			' Based on Perl SVG:TT:Graph by Leo Lapworth & Stephan Morgan ',
			' ' + '/' * 66,
		)
		list(map(self.root.append, map(etree.Comment, comment_strings)))

		defs = etree.SubElement(self.root, 'defs')
		self.add_defs(defs)

		if not hasattr(self, 'style_sheet_href') and not self.css_inline:
			self.root.append(etree.Comment(
				' include default stylesheet if none specified '))
			style = etree.SubElement(defs, 'style', type='text/css')
			# TODO: the text was previously escaped in a CDATA declaration... how
			#  to do that with etree?
			style.text = self.get_stylesheet().cssText

		self.root.append(etree.Comment('SVG Background'))
		etree.SubElement(self.root, 'rect', {
			'width': str(self.width),
			'height': str(self.height),
			'x': '0',
			'y': '0',
			'class': 'svgBackground'})
Base SVG Document Creation