def effect(self): input = file(self.args[0], "r") self.options.infilename = self.args[0] sys.stdout.write( scourString(input.read(), self.options).encode("UTF-8")) input.close() sys.stdout.close()
def do_svg(icon): with open(icon["src"], "r") as input_file: data = scour.scourString(input_file.read(), scour_options) with open(icon["dest_svg"], "w") as output_file: output_file.write(data)
def scourDoc(self, str): return scourString(str).encode("UTF-8")
def effect(self): input = file(self.args[0], "r") self.options.infilename=self.args[0] sys.stdout.write(scourString(input.read(), self.options).encode("UTF-8")) input.close() sys.stdout.close()
else: g.setAttribute('transform', "translate(-%f,-%f)" % (offsetx, offsety)) if(not args.skip_scour): options = _options_parser.get_default_values() options.strip_comments = not args.dont_strip_comments options.remove_metadata = not args.dont_remove_metadata options.enable_viewboxing = not args.disable_viewboxing options.indent_type = 'none' in_string = '' if(xml): in_string = xml.toxml() else: in_string = file(args.filename).read() out_string = scourString(in_string, options) xml = parseString(out_string) elif(not xml): xml = readin_xml(args.filename) svg = xml.getElementsByTagName('svg')[0] if(not args.disable_viebox_resizing): viewbox = '0 0 %f %f' % (maxwidth, maxheight) svg.setAttribute('viewBox', viewbox) defs = xml.createElement('defs') style = xml.createElement('style') styleText = xml.createTextNode("svg .sprite { display: none }\nsvg .sprite:target { display: inline } ") style.appendChild(styleText) defs.appendChild(style) svg.appendChild(defs)