X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=share%2Fextensions%2Fexport_gimp_palette.py;h=f1b4086c01ae41478360038ff958fdbbc430faa3;hb=cf5cee5fd8334d9064027cd5285b0db54c10f28a;hp=886ef6c879dc763b39e6717a88a86fcbf215b506;hpb=de654a4fb2adf892f6f43bcdba09984b69a491b6;p=inkscape.git diff --git a/share/extensions/export_gimp_palette.py b/share/extensions/export_gimp_palette.py index 886ef6c87..f1b4086c0 100644 --- a/share/extensions/export_gimp_palette.py +++ b/share/extensions/export_gimp_palette.py @@ -1,47 +1,50 @@ -#!/usr/bin/env python -''' -Author: Jos Hirth, kaioa.com -License: GNU General Public License - http://www.gnu.org/licenses/gpl.html -Warranty: see above -''' - -DOCNAME='sodipodi:docname' - -import sys, simplestyle -try: - from xml.dom.minidom import parse -except: - sys.exit('The export_gpl.py module requires PyXML. Please download the latest version from .') - -colortags=(u'fill',u'stroke',u'stop-color',u'flood-color',u'lighting-color') -colors={} - -def walk(node): - checkStyle(node) - if node.hasChildNodes(): - childs=node.childNodes - for child in childs: - walk(child) - -def checkStyle(node): - if node.hasAttributes(): - sa=node.getAttribute('style') - if sa!='': - styles=simplestyle.parseStyle(sa) - for c in range(len(colortags)): - if colortags[c] in styles.keys(): - addColor(styles[colortags[c]]) - -def addColor(col): - if simplestyle.isColor(col): - c=simplestyle.parseColor(col) - colors['%3i %3i %3i ' % (c[0],c[1],c[2])]=simplestyle.formatColoria(c).upper() - -stream = open(sys.argv[-1:][0],'r') -dom = parse(stream) -stream.close() -walk(dom) -print 'GIMP Palette\nName: %s\n#' % (dom.getElementsByTagName('svg')[0].getAttribute(DOCNAME).split('.')[0]) - -for k,v in sorted(colors.items()): - print k+v \ No newline at end of file +#!/usr/bin/env python +''' +Author: Jos Hirth, kaioa.com +License: GNU General Public License - http://www.gnu.org/licenses/gpl.html +Warranty: see above +''' + +DOCNAME='sodipodi:docname' + +import sys, simplestyle +try: + from xml.dom.minidom import parse +except: + sys.exit(_('The export_gpl.py module requires PyXML. Please download the latest version from http://pyxml.sourceforge.net/.')) + +colortags=(u'fill',u'stroke',u'stop-color',u'flood-color',u'lighting-color') +colors={} + +def walk(node): + checkStyle(node) + if node.hasChildNodes(): + childs=node.childNodes + for child in childs: + walk(child) + +def checkStyle(node): + if hasattr(node,"hasAttributes") and node.hasAttributes(): + sa=node.getAttribute('style') + if sa!='': + styles=simplestyle.parseStyle(sa) + for c in range(len(colortags)): + if colortags[c] in styles.keys(): + addColor(styles[colortags[c]]) + +def addColor(col): + if simplestyle.isColor(col): + c=simplestyle.parseColor(col) + colors['%3i %3i %3i ' % (c[0],c[1],c[2])]=simplestyle.formatColoria(c).upper() + +stream = open(sys.argv[-1:][0],'r') +dom = parse(stream) +stream.close() +walk(dom) +print 'GIMP Palette\nName: %s\n#' % (dom.getElementsByTagName('svg')[0].getAttribute(DOCNAME).split('.')[0]) + +for k,v in sorted(colors.items()): + print k+v + + +# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8