diff options
| author | su_v <suv-sf@users.sourceforge.net> | 2012-12-16 05:41:25 +0000 |
|---|---|---|
| committer | ~suv <suv-sf@users.sourceforge.net> | 2012-12-16 05:41:25 +0000 |
| commit | 7ec903c9898f872dbd9426ed7a62e1969fdb7be7 (patch) | |
| tree | a306139e829118a83516af02279c9eafd3440eaa /share/extensions | |
| parent | Hershey Text: whitespace; py: docstring, modeline; inx: fix attribute value (diff) | |
| parent | Translations.Spanish translation update by Lucas Vieites. (diff) | |
| download | inkscape-7ec903c9898f872dbd9426ed7a62e1969fdb7be7.tar.gz inkscape-7ec903c9898f872dbd9426ed7a62e1969fdb7be7.zip | |
merge from trunk (r11955)
(bzr r11687.1.3)
Diffstat (limited to 'share/extensions')
55 files changed, 411 insertions, 288 deletions
diff --git a/share/extensions/color_HSL_adjust.inx b/share/extensions/color_HSL_adjust.inx index 4c0330f53..b5a18c419 100644 --- a/share/extensions/color_HSL_adjust.inx +++ b/share/extensions/color_HSL_adjust.inx @@ -8,11 +8,11 @@ <param name="tab" type="notebook"> <page name="Options" _gui-text="Options"> <param name="hue" type="int" appearance="full" min="-360" max="360" indent="0" _gui-text="Hue (°):">0</param> - <param name="random_h" type="boolean" _gui-text="Ramdom hue">false</param> + <param name="random_h" type="boolean" _gui-text="Random hue">false</param> <param name="saturation" type="int" appearance="full" min="-100" max="100" indent="0" _gui-text="Saturation (%):">0</param> - <param name="random_s" type="boolean" _gui-text="Ramdom saturation">false</param> + <param name="random_s" type="boolean" _gui-text="Random saturation">false</param> <param name="lightness" type="int" appearance="full" min="-100" max="100" indent="0" _gui-text="Lightness (%):">0</param> - <param name="random_l" type="boolean" _gui-text="Ramdom lightness">false</param> + <param name="random_l" type="boolean" _gui-text="Random lightness">false</param> </page> <page name="Help" _gui-text="Help"> <_param name="instructions" type="description" xml:space="preserve">Adjusts hue, saturation and lightness in the HSL representation of the selected objects's color. diff --git a/share/extensions/convert2dashes.py b/share/extensions/convert2dashes.py index cf42a078a..9e7f6d439 100755 --- a/share/extensions/convert2dashes.py +++ b/share/extensions/convert2dashes.py @@ -20,10 +20,13 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' +# local library +import inkex +import cubicsuperpath +import bezmisc +import simplestyle -import inkex, cubicsuperpath, bezmisc, simplestyle -import gettext -_ = gettext.gettext +inkex.localize() def tpoint((x1,y1), (x2,y2), t = 0.5): return [x1+t*(x2-x1),y1+t*(y2-y1)] diff --git a/share/extensions/dimension.py b/share/extensions/dimension.py index 9156fdc2c..4285effeb 100755 --- a/share/extensions/dimension.py +++ b/share/extensions/dimension.py @@ -32,16 +32,19 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' -import sys, inkex, pathmodifier -from simpletransform import * -import gettext -_ = gettext.gettext - +# standard library +import sys try: from subprocess import Popen, PIPE bsubprocess = True except: bsubprocess = False +# local library +import inkex +import pathmodifier +from simpletransform import * + +inkex.localize() class Dimension(pathmodifier.PathModifier): def __init__(self): @@ -127,7 +130,8 @@ class Dimension(pathmodifier.PathModifier): try: testing_the_water = self.bbox[0] except TypeError: - sys.exit(_('Unable to process this object. Try changing it into a path first.')) + inkex.errormsg(_('Unable to process this object. Try changing it into a path first.')) + exit() layer = self.current_layer diff --git a/share/extensions/draw_from_triangle.py b/share/extensions/draw_from_triangle.py index 124824528..414363e86 100755 --- a/share/extensions/draw_from_triangle.py +++ b/share/extensions/draw_from_triangle.py @@ -30,12 +30,15 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' - -import inkex -import simplestyle, sys, simplepath +# standard library +import sys from math import * -import gettext -_ = gettext.gettext +# local library +import inkex +import simplestyle +import simplepath + +inkex.localize() #DRAWING ROUTINES diff --git a/share/extensions/dxf_outlines.py b/share/extensions/dxf_outlines.py index a5ff0f012..fd01e83e9 100755 --- a/share/extensions/dxf_outlines.py +++ b/share/extensions/dxf_outlines.py @@ -30,9 +30,17 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' -import inkex, simplestyle, simpletransform, cubicsuperpath, coloreffect, dxf_templates, math -import gettext -_ = gettext.gettext +# standard library +import math +# local library +import inkex +import simplestyle +import simpletransform +import cubicsuperpath +import coloreffect +import dxf_templates + +inkex.localize() try: from numpy import * diff --git a/share/extensions/embedimage.py b/share/extensions/embedimage.py index 882455cb0..bdc15bde2 100755 --- a/share/extensions/embedimage.py +++ b/share/extensions/embedimage.py @@ -16,10 +16,16 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' +# standard library +import base64 +import os +import sys +import urllib +import urlparse +# local library +import inkex -import inkex, os, base64, urlparse, urllib -import gettext -_ = gettext.gettext +inkex.localize() class Embedder(inkex.Effect): def __init__(self): @@ -69,12 +75,15 @@ class Embedder(inkex.Effect): if (absref != None): path=absref - path=unicode(path, "utf-8") - + try: + path=unicode(path, "utf-8") + except TypeError: + path=path + if (not os.path.isfile(path)): inkex.errormsg(_('No xlink:href or sodipodi:absref attributes found, or they do not point to an existing file! Unable to embed image.')) if path: - inkex.errormsg(_("Sorry we could not locate %s") % path) + inkex.errormsg(_("Sorry we could not locate %s") % str(path)) if (os.path.isfile(path)): file = open(path,"rb").read() diff --git a/share/extensions/export_gimp_palette.py b/share/extensions/export_gimp_palette.py index b9d6a1059..25856f4b4 100755 --- a/share/extensions/export_gimp_palette.py +++ b/share/extensions/export_gimp_palette.py @@ -7,11 +7,19 @@ Warranty: see above DOCNAME='sodipodi:docname' -import sys, simplestyle +# standard library +import sys +# third party 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/.')) + inkex.errormsg(_('The export_gpl.py module requires PyXML. Please download the latest version from http://pyxml.sourceforge.net/.')) + sys.exit() +# local library +import inkex +import simplestyle + +inkex.localize() colortags=(u'fill',u'stroke',u'stop-color',u'flood-color',u'lighting-color') colors={} diff --git a/share/extensions/extractimage.py b/share/extensions/extractimage.py index d5cf285c8..62dc83c87 100755 --- a/share/extensions/extractimage.py +++ b/share/extensions/extractimage.py @@ -16,10 +16,13 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' +# standard library +import base64 +import os +# local library +import inkex -import inkex, base64, os -import gettext -_ = gettext.gettext +inkex.localize() class MyEffect(inkex.Effect): def __init__(self): diff --git a/share/extensions/extrude.inx b/share/extensions/extrude.inx index dfae5d825..02a1bd803 100644 --- a/share/extensions/extrude.inx +++ b/share/extensions/extrude.inx @@ -1,20 +1,20 @@ <?xml version="1.0" encoding="UTF-8"?> <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>Extrude</_name> - <id>org.greygreen.inkscape.effects.extrude</id> + <_name>Extrude</_name> + <id>org.greygreen.inkscape.effects.extrude</id> <dependency type="executable" location="extensions">extrude.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> - <param name="mode" type="enum" _gui-text="Mode:"> - <_item>Lines</_item> - <_item>Polygons</_item> - </param> - <effect> + <param name="mode" type="enum" _gui-text="Mode:"> + <_item value="Lines">Lines</_item> + <_item value="Polygons">Polygons</_item> + </param> + <effect> <object-type>path</object-type> - <effects-menu> - <submenu _name="Generate from Path"/> - </effects-menu> - </effect> - <script> - <command reldir="extensions" interpreter="python">extrude.py</command> - </script> + <effects-menu> + <submenu _name="Generate from Path"/> + </effects-menu> + </effect> + <script> + <command reldir="extensions" interpreter="python">extrude.py</command> + </script> </inkscape-extension> diff --git a/share/extensions/extrude.py b/share/extensions/extrude.py index 88ad26e49..c91ea645e 100755 --- a/share/extensions/extrude.py +++ b/share/extensions/extrude.py @@ -16,10 +16,13 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' -import sys, os -sys.path.append(os.path.dirname(sys.argv[0])) #? +# local library +import inkex +import simplepath +import simpletransform +import cubicsuperpath -import inkex, simplepath, simpletransform, sys, cubicsuperpath +inkex.localize() class Extrude(inkex.Effect): def __init__(self): @@ -36,56 +39,55 @@ class Extrude(inkex.Effect): for id, node in self.selected.iteritems(): if node.tag == '{http://www.w3.org/2000/svg}path': paths.append(node) - if len(paths) == 2: - break - else: - sys.stderr.write('Need 2 paths selected\n') + if len(paths) < 2: + inkex.errormsg(_('Need at least 2 paths selected')) return - pts = [cubicsuperpath.parsePath(paths[i].get('d')) - for i in (0,1)] + for i in range(len(paths))] - for i in (0,1): + for i in range(len(paths)): if 'transform' in paths[i].keys(): trans = paths[i].get('transform') trans = simpletransform.parseTransform(trans) simpletransform.applyTransformToPath(trans, pts[i]) - verts = [] - for i in range(0, min(map(len, pts))): - comp = [] - for j in range(0, min(len(pts[0][i]), len(pts[1][i]))): - comp.append([pts[0][i][j][1][-2:], pts[1][i][j][1][-2:]]) - verts.append(comp) + for n1 in range(0, len(paths)): + for n2 in range(n1 + 1, len(paths)): + verts = [] + for i in range(0, min(map(len, pts))): + comp = [] + for j in range(0, min(len(pts[n1][i]), len(pts[n2][i]))): + comp.append([pts[n1][i][j][1][-2:], pts[n2][i][j][1][-2:]]) + verts.append(comp) - if self.options.mode.lower() == 'lines': - line = [] - for comp in verts: - for n,v in enumerate(comp): - line += [('M', v[0])] - line += [('L', v[1])] - ele = inkex.etree.Element('{http://www.w3.org/2000/svg}path') - paths[0].xpath('..')[0].append(ele) - ele.set('d', simplepath.formatPath(line)) - ele.set('style', 'fill:none;stroke:#000000;stroke-opacity:1;stroke-width:1;') - elif self.options.mode.lower() == 'polygons': - g = inkex.etree.Element('{http://www.w3.org/2000/svg}g') - g.set('style', 'fill:#000000;stroke:#000000;fill-opacity:0.3;stroke-width:2;stroke-opacity:0.6;') - paths[0].xpath('..')[0].append(g) - for comp in verts: - for n,v in enumerate(comp): - nn = n+1 - if nn == len(comp): nn = 0 + if self.options.mode.lower() == 'lines': line = [] - line += [('M', comp[n][0])] - line += [('L', comp[n][1])] - line += [('L', comp[nn][1])] - line += [('L', comp[nn][0])] - line += [('L', comp[n][0])] + for comp in verts: + for n,v in enumerate(comp): + line += [('M', v[0])] + line += [('L', v[1])] ele = inkex.etree.Element('{http://www.w3.org/2000/svg}path') - g.append(ele) + paths[0].xpath('..')[0].append(ele) ele.set('d', simplepath.formatPath(line)) + ele.set('style', 'fill:none;stroke:#000000;stroke-opacity:1;stroke-width:1;') + elif self.options.mode.lower() == 'polygons': + g = inkex.etree.Element('{http://www.w3.org/2000/svg}g') + g.set('style', 'fill:#000000;stroke:#000000;fill-opacity:0.3;stroke-width:2;stroke-opacity:0.6;') + paths[0].xpath('..')[0].append(g) + for comp in verts: + for n,v in enumerate(comp): + nn = n+1 + if nn == len(comp): nn = 0 + line = [] + line += [('M', comp[n][0])] + line += [('L', comp[n][1])] + line += [('L', comp[nn][1])] + line += [('L', comp[nn][0])] + line += [('L', comp[n][0])] + ele = inkex.etree.Element('{http://www.w3.org/2000/svg}path') + g.append(ele) + ele.set('d', simplepath.formatPath(line)) if __name__ == '__main__': #pragma: no cover diff --git a/share/extensions/funcplot.py b/share/extensions/funcplot.py index a868e92a4..08ac15dbb 100755 --- a/share/extensions/funcplot.py +++ b/share/extensions/funcplot.py @@ -25,11 +25,15 @@ Changes: * 21-Jun-2007: Tavmjong: Added polar coordinates ''' -import inkex, simplepath, simplestyle +# standard library from math import * from random import * -import gettext -_ = gettext.gettext +# local library +import inkex +import simplepath +import simplestyle + +inkex.localize() def drawfunction(xstart, xend, ybottom, ytop, samples, width, height, left, bottom, fx = "sin(x)", fpx = "cos(x)", fponum = True, times2pi = False, polar = False, isoscale = True, drawaxis = True, endpts = False): @@ -39,6 +43,9 @@ def drawfunction(xstart, xend, ybottom, ytop, samples, width, height, left, bott xend = 2 * pi * xend # coords and scales based on the source rect + if xstart == xend: + inkex.errormsg(_("x-interval cannot be zero. Please modify 'Start X' or 'End X'")) + return [] scalex = width / (xend - xstart) xoff = left coordx = lambda x: (x - xstart) * scalex + xoff #convert x-value to coordinate @@ -48,6 +55,9 @@ def drawfunction(xstart, xend, ybottom, ytop, samples, width, height, left, bott polar_scalex = width/2.0 coordx = lambda x: x * polar_scalex + centerx #convert x-value to coordinate + if ytop == ybottom: + inkex.errormsg(_("y-interval cannot be zero. Please modify 'Y top' or 'Y bottom'")) + return [] scaley = height / (ytop - ybottom) yoff = bottom coordy = lambda y: (ybottom - y) * scaley + yoff #convert y-value to coordinate diff --git a/share/extensions/gcodetools.py b/share/extensions/gcodetools.py index e5f1944b0..ff0454db0 100755 --- a/share/extensions/gcodetools.py +++ b/share/extensions/gcodetools.py @@ -68,9 +68,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA gcodetools_current_version = "1.7" -import inkex, simplestyle, simplepath -import cubicsuperpath, simpletransform, bezmisc - +# standard library import os import math import bezmisc @@ -82,9 +80,15 @@ import cmath import numpy import codecs import random -import gettext -_ = gettext.gettext +# local library +import inkex +import simplestyle +import simplepath +import cubicsuperpath +import simpletransform +import bezmisc +inkex.localize() ### Check if inkex has errormsg (0.46 version does not have one.) Could be removed later. if "errormsg" not in dir(inkex): diff --git a/share/extensions/gears.inx b/share/extensions/gears.inx index f5bc23550..78d556b4a 100644 --- a/share/extensions/gears.inx +++ b/share/extensions/gears.inx @@ -13,7 +13,7 @@ <_option value="in">in</_option> <_option value="mm">mm</_option> </param> - <_param name="unit_text" type="description">Unit of measure for both circular pitch and center diameter.</_param> + <_param name="unit_text" type="description">Unit of measurement for both circular pitch and center diameter.</_param> <effect> <object-type>all</object-type> <effects-menu> diff --git a/share/extensions/generate_voronoi.py b/share/extensions/generate_voronoi.py index 54400a90a..4ab67dcd6 100755 --- a/share/extensions/generate_voronoi.py +++ b/share/extensions/generate_voronoi.py @@ -20,14 +20,20 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ -import random, inkex, simplestyle, gettext, voronoi -_ = gettext.gettext +# standard library +import random +# local library +import inkex +import simplestyle +import voronoi + +inkex.localize() try: from subprocess import Popen, PIPE except: - inkex.errormsg(_("Failed to import the subprocess module. Please report this as a bug at : https://bugs.launchpad.net/inkscape.")) - inkex.errormsg("Python version is : " + str(inkex.sys.version_info)) + inkex.errormsg(_("Failed to import the subprocess module. Please report this as a bug at: https://bugs.launchpad.net/inkscape.")) + inkex.errormsg(_("Python version is: ") + str(inkex.sys.version_info)) exit() def clip_line(x1, y1, x2, y2, w, h): diff --git a/share/extensions/gimp_xcf.py b/share/extensions/gimp_xcf.py index de3d67de6..ff1589cd8 100755 --- a/share/extensions/gimp_xcf.py +++ b/share/extensions/gimp_xcf.py @@ -18,17 +18,16 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' - -import gettext +# standard library import os import shutil from subprocess import Popen, PIPE import sys import tempfile - +# local library import inkex -_ = gettext.gettext +inkex.localize() # Define extension exceptions class GimpXCFError(Exception): pass diff --git a/share/extensions/guides_creator.py b/share/extensions/guides_creator.py index 96f2557ee..e7458b81e 100755 --- a/share/extensions/guides_creator.py +++ b/share/extensions/guides_creator.py @@ -43,18 +43,16 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import sys sys.path.append('/usr/share/inkscape/extensions') -# We will use the inkex module with the predefined Effect base class. -import inkex -from simplestyle import * - from xml.etree import ElementTree as ET - # for golden number formulae from math import sqrt -# for printing debugging output -import gettext -_ = gettext.gettext +# We will use the inkex module with the predefined Effect base class. +import inkex +from simplestyle import * + +# for localized debugging output +inkex.localize() def printDebug(string): inkex.errormsg(_(string)) diff --git a/share/extensions/guillotine.py b/share/extensions/guillotine.py index bda56b206..82b1a5441 100755 --- a/share/extensions/guillotine.py +++ b/share/extensions/guillotine.py @@ -37,22 +37,22 @@ will export to: etc. ''' - +# standard library +import locale import os import sys -import inkex -import simplestyle -import locale -import gettext -_ = gettext.gettext - -locale.setlocale(locale.LC_ALL, '') - try: from subprocess import Popen, PIPE bsubprocess = True except: bsubprocess = False +# local library +import inkex +import simplestyle + +inkex.localize() + +locale.setlocale(locale.LC_ALL, '') def float_sort(a, b): ''' diff --git a/share/extensions/inkex.py b/share/extensions/inkex.py index 6a29e3f64..4ba88c3bb 100755 --- a/share/extensions/inkex.py +++ b/share/extensions/inkex.py @@ -33,25 +33,8 @@ import os import random import re import sys - from math import * -domain = 'inkscape' -if sys.platform.startswith('win'): - import locale - current_locale, encoding = locale.getdefaultlocale() - os.environ['LANG'] = current_locale - try: - localdir = os.environ['INKSCAPE_LOCALEDIR']; - #sys.stderr.write(str(localdir) + "\n") - gettext= gettext.translation(domain, localdir, [current_locale], fallback=True) - except KeyError: - gettext= gettext.translation(domain, fallback=True) -else: - gettext= gettext.translation(domain, fallback=True) - -_ = gettext.gettext - #a dictionary of all of the xmlns prefixes in a standard inkscape doc NSS = { u'sodipodi' :u'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd', @@ -65,6 +48,36 @@ u'xlink' :u'http://www.w3.org/1999/xlink', u'xml' :u'http://www.w3.org/XML/1998/namespace' } +def localize(): + domain = 'inkscape' + if sys.platform.startswith('win'): + import locale + current_locale, encoding = locale.getdefaultlocale() + os.environ['LANG'] = current_locale + try: + localdir = os.environ['INKSCAPE_LOCALEDIR']; + trans = gettext.translation(domain, localdir, [current_locale], fallback=True) + except KeyError: + trans = gettext.translation(domain, fallback=True) + elif sys.platform.startswith('darwin'): + try: + localdir = os.environ['INKSCAPE_LOCALEDIR']; + trans = gettext.translation(domain, localdir, fallback=True) + except KeyError: + try: + localdir = os.environ['PACKAGE_LOCALE_DIR']; + trans = gettext.translation(domain, localdir, fallback=True) + except KeyError: + trans = gettext.translation(domain, fallback=True) + else: + try: + localdir = os.environ['PACKAGE_LOCALE_DIR']; + trans = gettext.translation(domain, localdir, fallback=True) + except KeyError: + trans = gettext.translation(domain, fallback=True) + #sys.stderr.write(str(localdir) + "\n") + trans.install() + #a dictionary of unit to user unit conversion factors uuconv = {'in':90.0, 'pt':1.25, 'px':1, 'mm':3.5433070866, 'cm':35.433070866, 'm':3543.3070866, 'km':3543307.0866, 'pc':15.0, 'yd':3240 , 'ft':1080} @@ -89,12 +102,6 @@ def unittouu(string): def uutounit(val, unit): return val/uuconv[unit] -try: - from lxml import etree -except Exception, e: - sys.exit(_("The fantastic lxml wrapper for libxml2 is required by inkex.py and therefore this extension. Please download and install the latest version from http://cheeseshop.python.org/pypi/lxml/, or install it through your package manager by a command like: sudo apt-get install python-lxml\n\nTechnical details:\n%s" % (e,))) - - def debug(what): sys.stderr.write(str(what) + "\n") return what @@ -108,16 +115,24 @@ def errormsg(msg): Note that this should always be combined with translation: - import gettext - _ = gettext.gettext + import inkex + inkex.localize() ... inkex.errormsg(_("This extension requires two selected paths.")) """ if isinstance(msg, unicode): - sys.stderr.write(_(msg).encode("UTF-8") + "\n") + sys.stderr.write(msg.encode("UTF-8") + "\n") else: - sys.stderr.write((unicode(_(msg), "utf-8", errors='replace') + "\n").encode("UTF-8")) + sys.stderr.write((unicode(msg, "utf-8", errors='replace') + "\n").encode("UTF-8")) +# third party library +try: + from lxml import etree +except Exception, e: + localize() + errormsg(_("The fantastic lxml wrapper for libxml2 is required by inkex.py and therefore this extension. Please download and install the latest version from http://cheeseshop.python.org/pypi/lxml/, or install it through your package manager by a command like: sudo apt-get install python-lxml\n\nTechnical details:\n%s" % (e,))) + sys.exit() + def check_inkbool(option, opt, value): if str(value).capitalize() == 'True': return True diff --git a/share/extensions/interp_att_g.py b/share/extensions/interp_att_g.py index 5f2b3574a..8ceaf8e34 100755 --- a/share/extensions/interp_att_g.py +++ b/share/extensions/interp_att_g.py @@ -16,9 +16,15 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' -import inkex, simplestyle, math, re, string -import gettext -_ = gettext.gettext +# standard library +import math +import re +import string +# local library +import inkex +import simplestyle + +inkex.localize() class InterpAttG(inkex.Effect): diff --git a/share/extensions/jessyInk_autoTexts.py b/share/extensions/jessyInk_autoTexts.py index cf41ad24f..ed0edb6fa 100755 --- a/share/extensions/jessyInk_autoTexts.py +++ b/share/extensions/jessyInk_autoTexts.py @@ -25,8 +25,7 @@ sys.path.append('C:\Program Files\Inkscape\share\extensions') # We will use the inkex module with the predefined Effect base class. import inkex -import gettext -_ = gettext.gettext +inkex.localize() class JessyInk_AutoTexts(inkex.Effect): def __init__(self): diff --git a/share/extensions/jessyInk_effects.py b/share/extensions/jessyInk_effects.py index 3af909bb2..e20e9fc2c 100755 --- a/share/extensions/jessyInk_effects.py +++ b/share/extensions/jessyInk_effects.py @@ -25,8 +25,7 @@ sys.path.append('C:\Program Files\Inkscape\share\extensions') # We will use the inkex module with the predefined Effect base class. import inkex -import gettext -_ = gettext.gettext +inkex.localize() class JessyInk_Effects(inkex.Effect): def __init__(self): diff --git a/share/extensions/jessyInk_export.py b/share/extensions/jessyInk_export.py index 65247ab7e..71907e276 100755 --- a/share/extensions/jessyInk_export.py +++ b/share/extensions/jessyInk_export.py @@ -30,8 +30,8 @@ import os import zipfile import glob import re -import gettext -_ = gettext.gettext + +inkex.localize() def propStrToDict(inStr): dictio = {} diff --git a/share/extensions/jessyInk_keyBindings.py b/share/extensions/jessyInk_keyBindings.py index 110ca3355..df50f4447 100755 --- a/share/extensions/jessyInk_keyBindings.py +++ b/share/extensions/jessyInk_keyBindings.py @@ -25,8 +25,8 @@ sys.path.append('C:\Program Files\Inkscape\share\extensions') # We will use the inkex module with the predefined Effect base class. import inkex -import gettext -_ = gettext.gettext + +inkex.localize() class JessyInk_CustomKeyBindings(inkex.Effect): modes = ('slide', 'index', 'drawing') diff --git a/share/extensions/jessyInk_masterSlide.py b/share/extensions/jessyInk_masterSlide.py index c29922d94..eca7711ff 100755 --- a/share/extensions/jessyInk_masterSlide.py +++ b/share/extensions/jessyInk_masterSlide.py @@ -25,8 +25,8 @@ sys.path.append('C:\Program Files\Inkscape\share\extensions') # We will use the inkex module with the predefined Effect base class. import inkex -import gettext -_ = gettext.gettext + +inkex.localize() class JessyInk_MasterSlide(inkex.Effect): def __init__(self): diff --git a/share/extensions/jessyInk_mouseHandler.py b/share/extensions/jessyInk_mouseHandler.py index 4eff4c467..fafc8eec3 100755 --- a/share/extensions/jessyInk_mouseHandler.py +++ b/share/extensions/jessyInk_mouseHandler.py @@ -27,8 +27,8 @@ sys.path.append('C:\Program Files\Inkscape\share\extensions') # We will use the inkex module with the predefined Effect base class. import inkex -import gettext -_ = gettext.gettext + +inkex.localize() class JessyInk_CustomMouseHandler(inkex.Effect): def __init__(self): diff --git a/share/extensions/jessyInk_summary.py b/share/extensions/jessyInk_summary.py index 48478c41e..feff79b37 100755 --- a/share/extensions/jessyInk_summary.py +++ b/share/extensions/jessyInk_summary.py @@ -25,8 +25,8 @@ sys.path.append('C:\Program Files\Inkscape\share\extensions') # We will use the inkex module with the predefined Effect base class. import inkex -import gettext -_ = gettext.gettext + +inkex.localize() def propStrToList(str): list = [] @@ -71,7 +71,7 @@ class JessyInk_Summary(inkex.Effect): inkex.errormsg(_("JessyInk script installed.")) slides = [] - masterSlide = None + masterSlide = None for node in self.document.xpath("//svg:g[@inkscape:groupmode='layer']", namespaces=inkex.NSS): if node.get("{" + inkex.NSS["jessyink"] + "}masterSlide"): diff --git a/share/extensions/jessyInk_transitions.py b/share/extensions/jessyInk_transitions.py index 18cd3f880..bfd75584c 100755 --- a/share/extensions/jessyInk_transitions.py +++ b/share/extensions/jessyInk_transitions.py @@ -25,8 +25,8 @@ sys.path.append('C:\Program Files\Inkscape\share\extensions') # We will use the inkex module with the predefined Effect base class. import inkex -import gettext -_ = gettext.gettext + +inkex.localize() class JessyInk_Transitions(inkex.Effect): def __init__(self): diff --git a/share/extensions/jessyInk_video.py b/share/extensions/jessyInk_video.py index 51c73494b..bca98e9a7 100755 --- a/share/extensions/jessyInk_video.py +++ b/share/extensions/jessyInk_video.py @@ -29,8 +29,8 @@ import os import re from lxml import etree from copy import deepcopy -import gettext -_ = gettext.gettext + +inkex.localize() class JessyInk_Effects(inkex.Effect): def __init__(self): diff --git a/share/extensions/jessyInk_view.py b/share/extensions/jessyInk_view.py index 04adc27ae..ee71a1d35 100755 --- a/share/extensions/jessyInk_view.py +++ b/share/extensions/jessyInk_view.py @@ -25,8 +25,8 @@ sys.path.append('C:\Program Files\Inkscape\share\extensions') # We will use the inkex module with the predefined Effect base class. import inkex -import gettext -_ = gettext.gettext + +inkex.localize() def propStrToList(str): list = [] diff --git a/share/extensions/launch_webbrowser.py b/share/extensions/launch_webbrowser.py index 387d8b2cb..27a738e38 100755 --- a/share/extensions/launch_webbrowser.py +++ b/share/extensions/launch_webbrowser.py @@ -1,10 +1,11 @@ #!/usr/bin/env python -import gettext +# standard library import webbrowser import threading from optparse import OptionParser - -_ = gettext.gettext +# local library +import inkex +inkex.localize() class VisitWebSiteWithoutLockingInkscape(threading.Thread): def __init__(self): diff --git a/share/extensions/markers_strokepaint.py b/share/extensions/markers_strokepaint.py index 5c760cd17..d92716939 100755 --- a/share/extensions/markers_strokepaint.py +++ b/share/extensions/markers_strokepaint.py @@ -17,9 +17,14 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' -import random, inkex, simplestyle, copy -import gettext -_ = gettext.gettext +# standard library +import random +import copy +# local library +import inkex +import simplestyle + +inkex.localize() class MyEffect(inkex.Effect): def __init__(self): diff --git a/share/extensions/pathalongpath.py b/share/extensions/pathalongpath.py index 71f389e1c..7da7f1797 100755 --- a/share/extensions/pathalongpath.py +++ b/share/extensions/pathalongpath.py @@ -30,12 +30,19 @@ as painted on these lines. Now move and bend L to make it fit a skeleton, and see what happens to the normals: they move and rotate, deforming the pattern. ''' - -import inkex, cubicsuperpath, bezmisc -import pathmodifier,simpletransform -import copy, math, re, random -import gettext -_ = gettext.gettext +# standard library +import copy +import math +import re +import random +# local library +import inkex +import cubicsuperpath +import bezmisc +import pathmodifier +import simpletransform + +inkex.localize() def flipxy(path): for pathcomp in path: diff --git a/share/extensions/pathmodifier.py b/share/extensions/pathmodifier.py index ceb0994e6..ff2bbfb3a 100755 --- a/share/extensions/pathmodifier.py +++ b/share/extensions/pathmodifier.py @@ -27,11 +27,19 @@ to implement deformations of the form X=f(x,y), Y=g(x,y)... TODO: Several handy functions are defined, that might in fact be of general interest and that should be shipped out in separate files... ''' -import inkex, cubicsuperpath, bezmisc, simplestyle +# standard library +import copy +import math +import re +import random +# local library +import inkex +import cubicsuperpath +import bezmisc +import simplestyle from simpletransform import * -import copy, math, re, random -import gettext -_ = gettext.gettext + +inkex.localize() #################################################################### ##-- zOrder computation... diff --git a/share/extensions/pathscatter.py b/share/extensions/pathscatter.py index 6ed3cc8ac..268e31069 100755 --- a/share/extensions/pathscatter.py +++ b/share/extensions/pathscatter.py @@ -30,13 +30,21 @@ as painted on these lines. Now move and bend L to make it fit a skeleton, and see what happens to the normals: they move and rotate, deforming the pattern. ''' - -import inkex, cubicsuperpath, bezmisc -import pathmodifier, simpletransform +# standard library +import copy +import math +import re +import random +# third party from lxml import etree -import copy, math, re, random -import gettext -_ = gettext.gettext +# local library +import inkex +import cubicsuperpath +import bezmisc +import pathmodifier +import simpletransform + +inkex.localize() def zSort(inNode,idList): sortedList=[] diff --git a/share/extensions/perspective.py b/share/extensions/perspective.py index 733fb121a..8a0ffeb0b 100755 --- a/share/extensions/perspective.py +++ b/share/extensions/perspective.py @@ -18,10 +18,26 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Perspective approach & math by Dmitry Platonov, shadowjack@mail.ru, 2006 """ -import sys, inkex, os, re, simplepath, cubicsuperpath, simpletransform, voronoi2svg -import gettext -_ = gettext.gettext +# standard library +import sys +import os +import re +try: + from subprocess import Popen, PIPE + bsubprocess = True +except: + bsubprocess = False +# local library +import inkex +import simplepath +import cubicsuperpath +import simpletransform +import voronoi2svg from ffgeom import * + +inkex.localize() + +# third party try: from numpy import * from numpy.linalg import * @@ -29,30 +45,6 @@ except: inkex.errormsg(_("Failed to import the numpy or numpy.linalg modules. These modules are required by this extension. Please install them and try again. On a Debian-like system this can be done with the command, sudo apt-get install python-numpy.")) exit() -try: - from subprocess import Popen, PIPE - bsubprocess = True -except: - bsubprocess = False - -uuconv = {'in':90.0, 'pt':1.25, 'px':1, 'mm':3.5433070866, 'cm':35.433070866, 'pc':15.0} -def unittouu(string): - unit = re.compile('(%s)$' % '|'.join(uuconv.keys())) - param = re.compile(r'(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)') - - p = param.match(string) - u = unit.search(string) - if p: - retval = float(p.string[p.start():p.end()]) - else: - retval = 0.0 - if u: - try: - return retval * uuconv[u.string[u.start():u.end()]] - except KeyError: - pass - return retval - class Project(inkex.Effect): def __init__(self): inkex.Effect.__init__(self) diff --git a/share/extensions/polyhedron_3d.py b/share/extensions/polyhedron_3d.py index 1efce876f..063912cc2 100755 --- a/share/extensions/polyhedron_3d.py +++ b/share/extensions/polyhedron_3d.py @@ -48,12 +48,17 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' - -import inkex -import simplestyle, sys, re +# standard library +import sys +import re from math import * -import gettext -_ = gettext.gettext +# local library +import inkex +import simplestyle + +inkex.localize() + +# third party try: from numpy import * except: diff --git a/share/extensions/print_win32_vector.py b/share/extensions/print_win32_vector.py index 49baec136..e77b49826 100644 --- a/share/extensions/print_win32_vector.py +++ b/share/extensions/print_win32_vector.py @@ -27,11 +27,15 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' - +# standard library from ctypes import * -import inkex, simplestyle, simpletransform, cubicsuperpath -import gettext -_ = gettext.gettext +# local library +import inkex +import simplestyle +import simpletransform +import cubicsuperpath + +inkex.localize() if not inkex.sys.platform.startswith('win'): exit(_("sorry, this will run only on Windows, exiting...")) diff --git a/share/extensions/render_alphabetsoup.py b/share/extensions/render_alphabetsoup.py index f682e9b57..ad43163e4 100755 --- a/share/extensions/render_alphabetsoup.py +++ b/share/extensions/render_alphabetsoup.py @@ -18,22 +18,23 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' - +# standard library import copy -import inkex -import simplestyle import math import cmath import string import random -import render_alphabetsoup_config -import bezmisc -import simplepath import os import sys import re -import gettext -_ = gettext.gettext +# local library +import inkex +import simplestyle +import render_alphabetsoup_config +import bezmisc +import simplepath + +inkex.localize() syntax = render_alphabetsoup_config.syntax alphabet = render_alphabetsoup_config.alphabet diff --git a/share/extensions/render_barcode_datamatrix.py b/share/extensions/render_barcode_datamatrix.py index 20bcf94dc..2d28bb433 100755 --- a/share/extensions/render_barcode_datamatrix.py +++ b/share/extensions/render_barcode_datamatrix.py @@ -51,11 +51,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0.50 2009-10-25 Full functionality, up to 144x144. ASCII and compressed digit encoding only. ''' +# local library +import inkex +import simplestyle -import inkex, simplestyle - -import gettext -_ = gettext.gettext +inkex.localize() symbols = { 'sq10': (10, 10), diff --git a/share/extensions/render_barcode_qrcode.py b/share/extensions/render_barcode_qrcode.py index 2ed649a8f..8147d49a6 100755 --- a/share/extensions/render_barcode_qrcode.py +++ b/share/extensions/render_barcode_qrcode.py @@ -3,6 +3,8 @@ import math, sys import inkex +inkex.localize() + #QRCode for Python # #Ported from the Javascript library by Sam Curren diff --git a/share/extensions/replace_font.py b/share/extensions/replace_font.py index f0f25ab8e..090920ced 100755 --- a/share/extensions/replace_font.py +++ b/share/extensions/replace_font.py @@ -27,13 +27,14 @@ font. It can also replace all fonts indiscriminately, and list all fonts currently being used. ''' - +# standard library import os import sys +# local library import inkex import simplestyle -import gettext -_ = gettext.gettext + +inkex.localize() text_tags = ['{http://www.w3.org/2000/svg}tspan', '{http://www.w3.org/2000/svg}text', diff --git a/share/extensions/scour.inkscape.py b/share/extensions/scour.inkscape.py index 1cc7744d9..f161a09c2 100755 --- a/share/extensions/scour.inkscape.py +++ b/share/extensions/scour.inkscape.py @@ -65,8 +65,9 @@ class ScourInkscape (inkex.Effect): action="store", dest="renderer_workaround", default=False, help="work around various renderer bugs (currently only librsvg)") - def effect(self): + 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() diff --git a/share/extensions/summersnight.py b/share/extensions/summersnight.py index 3bfa70cbd..aea5cea55 100755 --- a/share/extensions/summersnight.py +++ b/share/extensions/summersnight.py @@ -17,18 +17,17 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ -import gettext +# standard library import os - +# local library import cubicsuperpath import inkex import simplepath import simpletransform import voronoi2svg - from ffgeom import * -_ = gettext.gettext +inkex.localize() try: from subprocess import Popen, PIPE diff --git a/share/extensions/svg_and_media_zip_output.py b/share/extensions/svg_and_media_zip_output.py index 62e2b2ef5..20a5dac18 100755 --- a/share/extensions/svg_and_media_zip_output.py +++ b/share/extensions/svg_and_media_zip_output.py @@ -36,8 +36,7 @@ TODOs - maybe add better extention - consider switching to lzma in order to allow cross platform compression with no encoding problem... ''' - -import inkex +# standard library import urlparse import urllib import os, os.path @@ -46,11 +45,13 @@ import zipfile import shutil import sys import tempfile -import simplestyle -import gettext import locale +# local library +import inkex +import simplestyle + locale.setlocale(locale.LC_ALL, '') -_ = gettext.gettext +inkex.localize() class CompressedMediaOutput(inkex.Effect): def __init__(self): diff --git a/share/extensions/svgcalendar.py b/share/extensions/svgcalendar.py index 818dbd0a4..b6d360ab0 100755 --- a/share/extensions/svgcalendar.py +++ b/share/extensions/svgcalendar.py @@ -37,6 +37,8 @@ from datetime import * import inkex import simplestyle +inkex.localize() + class SVGCalendar (inkex.Effect): def __init__(self): diff --git a/share/extensions/test/Makefile.am b/share/extensions/test/Makefile.am index eb63f357b..f7c59970f 100644 --- a/share/extensions/test/Makefile.am +++ b/share/extensions/test/Makefile.am @@ -42,7 +42,6 @@ EXTRA_DIST = \ perfectboundcover.test.py \ perspective.test.py \ polyhedron_3d.test.py \ - printing-marks.test.py \ radiusrand.test.py \ render_alphabetsoup.test.py \ render_barcode.test.py \ diff --git a/share/extensions/uniconv-ext.py b/share/extensions/uniconv-ext.py index 246340e89..5608000c4 100755 --- a/share/extensions/uniconv-ext.py +++ b/share/extensions/uniconv-ext.py @@ -20,14 +20,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ - +# standard library import sys -from run_command import run -import gettext -_ = gettext.gettext - -cmd = None - try: from subprocess import Popen, PIPE p = Popen('uniconvertor', shell=True, stdout=PIPE, stderr=PIPE).wait() @@ -43,6 +37,13 @@ except ImportError: if p!=32512 : cmd = 'uniconv' p = Popen3('uniconvertor', True).wait() if p!=32512 : cmd = 'uniconvertor' +# local library +from run_command import run +import inkex + +cmd = None + +inkex.localize() if cmd == None: # there's no succeffully-returning uniconv command; try to get the module directly (on Windows) diff --git a/share/extensions/uniconv_output.py b/share/extensions/uniconv_output.py index 30d1c2fe0..93236483d 100755 --- a/share/extensions/uniconv_output.py +++ b/share/extensions/uniconv_output.py @@ -28,11 +28,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA # On failure, outputs an error message to stderr, and exits with a return # code of 1. +# standard library import os import sys import tempfile -import gettext -_ = gettext.gettext +# local library +import inkex +inkex.localize() def run(command_format, prog_name, uniconv_format): outfile = tempfile.mktemp(uniconv_format) diff --git a/share/extensions/voronoi2svg.py b/share/extensions/voronoi2svg.py index 7687bba91..dd693f8bb 100755 --- a/share/extensions/voronoi2svg.py +++ b/share/extensions/voronoi2svg.py @@ -27,11 +27,17 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ -import sys, os -import inkex, simplestyle, simplepath, simpletransform +# standard library +import sys +import os +# local library +import inkex +import simplestyle +import simplepath +import simpletransform import voronoi -import gettext -_ = gettext.gettext + +inkex.localize() class Point: def __init__(self,x,y): diff --git a/share/extensions/web-set-att.py b/share/extensions/web-set-att.py index 65dd5a5b4..b224ed9aa 100755 --- a/share/extensions/web-set-att.py +++ b/share/extensions/web-set-att.py @@ -16,9 +16,11 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' -import inkwebeffect, gettext +# local library +import inkwebeffect +import inkex -_ = gettext.gettext +inkex.localize() class InkWebTransmitAtt(inkwebeffect.InkWebEffect): diff --git a/share/extensions/web-transmit-att.py b/share/extensions/web-transmit-att.py index 35f16e145..414eb12ea 100755 --- a/share/extensions/web-transmit-att.py +++ b/share/extensions/web-transmit-att.py @@ -16,9 +16,11 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' -import inkwebeffect, gettext +# local library +import inkwebeffect +import inkex -_ = gettext.gettext +inkex.localize() class InkWebTransmitAtt(inkwebeffect.InkWebEffect): diff --git a/share/extensions/webslicer_create_group.py b/share/extensions/webslicer_create_group.py index 613162850..dd48c3e96 100755 --- a/share/extensions/webslicer_create_group.py +++ b/share/extensions/webslicer_create_group.py @@ -16,12 +16,11 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' - +# local library from webslicer_effect import * import inkex -import gettext -_ = gettext.gettext +inkex.localize() class WebSlicer_CreateGroup(WebSlicer_Effect): diff --git a/share/extensions/webslicer_create_rect.py b/share/extensions/webslicer_create_rect.py index 9e916532f..7c04e8706 100755 --- a/share/extensions/webslicer_create_rect.py +++ b/share/extensions/webslicer_create_rect.py @@ -16,12 +16,11 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' - +# local library from webslicer_effect import * import inkex -import gettext -_ = gettext.gettext +inkex.localize() class WebSlicer_CreateRect(WebSlicer_Effect): diff --git a/share/extensions/webslicer_export.py b/share/extensions/webslicer_export.py index c50cbcc32..118dfbeee 100755 --- a/share/extensions/webslicer_export.py +++ b/share/extensions/webslicer_export.py @@ -16,15 +16,15 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' - -from webslicer_effect import * -import inkex -import gettext +# standard library import os import sys import tempfile +# local library +from webslicer_effect import * +import inkex -_ = gettext.gettext +inkex.localize() class WebSlicer_Export(WebSlicer_Effect): diff --git a/share/extensions/wireframe_sphere.py b/share/extensions/wireframe_sphere.py index 467aa609e..5804a1b45 100755 --- a/share/extensions/wireframe_sphere.py +++ b/share/extensions/wireframe_sphere.py @@ -54,13 +54,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Hidden lines of latitude still not properly calculated. Prolate and oblate spheroids not considered. ''' - -import inkex, simplestyle - -import gettext -_ = gettext.gettext - +# standard library from math import * +# local library +import inkex +import simplestyle + +inkex.localize() #SVG OUTPUT FUNCTIONS ================================================ def draw_SVG_ellipse((rx, ry), (cx, cy), parent, start_end=(0,2*pi),transform='' ): |
