# -*- coding: utf-8 -*- #Copyright (c) 2011, Walter Bender # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. import gtk from math import sin, cos, pi def generate_xo_svg(scale=1.0, colors=["#C0C0C0", "#282828"]): ''' Returns an SVG string representing an XO image ''' return svg_header(55, 55, scale) + \ _svg_xo(colors[0], colors[1]) + \ svg_footer() def svg_str_to_pixbuf(svg_string): ''' Load pixbuf from SVG string ''' pl = gtk.gdk.PixbufLoader('svg') pl.write(svg_string) pl.close() pixbuf = pl.get_pixbuf() return pixbuf def svg_sector(x, y, r, a, fill, stroke): ''' Returns an SVG sector ''' if a < pi: big_arc = 0 else: big_arc = 1 svg_string = ' \n' % (extras) def svg_from_file(pathname): ''' Read SVG string from a file ''' f = file(pathname, 'r') svg = f.read() f.close() return(svg) def extract_svg_payload(fd): """Returns everything between and """ payload = '' looking_for_start_svg_token = True looking_for_close_token = True looking_for_end_svg_token = True for line in fd: if looking_for_start_svg_token: if line.find('') < 0: continue looking_for_close_token = False line = line.split('>', 1)[1] if looking_for_end_svg_token: if line.find('') < 0: payload += line continue payload += line.split('')[0] break return payload