summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a223910)
raw | patch | inline | side by side (parent: a223910)
author | pjrm <pjrm@users.sourceforge.net> | |
Fri, 23 May 2008 12:49:19 +0000 (12:49 +0000) | ||
committer | pjrm <pjrm@users.sourceforge.net> | |
Fri, 23 May 2008 12:49:19 +0000 (12:49 +0000) |
share/extensions/inkex.py: (errormsg): New function.
14 files changed:
diff --git a/ChangeLog b/ChangeLog
index 35bee2e1f66287b173019b466ee1b0f46c0d889e..1e53daa2f7d0d7ca0854bd53c6902d244f86f9e1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2008-05-23 Peter Moulder <pmoulder@mail.csse.monash.edu.au>
+
+ * share/extensions/*.py: Use gettext for (many) error messages.
+ share/extensions/inkex.py: (errormsg): New function.
+
2007-06-24 Joel Holdsworth <joelholdsworth@yahoo.com>
* modified the windows RC files to add version info and manifest data
index f7dfb902e8e78c3a4fcc18190fe1af26696f0f40..4ff7148ef8a6ca2a1cb037289265abeae17506e0 100644 (file)
try:
testing_the_water = self.bbox[0]
except TypeError:
- sys.exit('Unable to process this object. Try changing it into a path first.')
+ sys.exit(_('Unable to process this object. Try changing it into a path first.'))
layer = self.current_layer
index 01cefacb00cb350956c20c8f20a55a203b30564d..059bc063e177369ceabb7fef1b75be4dabe76c80 100644 (file)
'''
import inkex, os, base64
+import gettext
+_ = gettext.gettext
class Embedder(inkex.Effect):
def __init__(self):
if (absref != None):
path=absref
if (not os.path.isfile(path)):
- inkex.debug('No xlink:href or sodipodi:absref attributes found, or they do not point to an existing file! Unable to embed image.')
+ inkex.errormsg(_('No xlink:href or sodipodi:absref attributes found, or they do not point to an existing file! Unable to embed image.'))
if (os.path.isfile(path)):
file = open(path,"rb").read()
if (absref != None):
del node.attrib[inkex.addNS('absref',u'sodipodi')]
else:
- inkex.debug("%s is not of type image/png, image/jpeg, image/bmp, image/gif or image/x-icon" % path)
+ inkex.errormsg(_("%s is not of type image/png, image/jpeg, image/bmp, image/gif or image/x-icon") % path)
else:
- inkex.debug("Sorry we could not locate %s" % path)
+ inkex.errormsg(_("Sorry we could not locate %s") % path)
if __name__ == '__main__':
e = Embedder()
index 31dad455283893d8374ad0e8d089548a9f1d9157..1248a56bbed868c72d154351f6a914ba112339d3 100644 (file)
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/>.')
+ 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={}
print k+v
-# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99
+# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8
index 07074c8a4693fd47527246267ad35b6531a896fe..38f9298465d66191fd3eb9718dd08fb5f8a0c21c 100644 (file)
'''
import inkex, base64, os
+import gettext
+_ = gettext.gettext
class MyEffect(inkex.Effect):
def __init__(self):
open(path,'wb').write(data)
node.set(inkex.addNS('href','xlink'),os.path.realpath(path)) #absolute for making in-mem cycles work
else:
- inkex.debug('Difficulty finding the image data.')
+ inkex.errormsg(_('Difficulty finding the image data.'))
break
if __name__ == '__main__':
index 5aa8912a9a1bf9f2b8e8afd7edf1dd9c1b7e5866..b4872368e02489027cfaf277dfe0db600c9d5a5e 100755 (executable)
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
import sys, copy, optparse, random, re
+import gettext
+_ = gettext.gettext
#a dictionary of all of the xmlns prefixes in a standard inkscape doc
NSS = {
try:
from lxml import etree
except:
- 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')
+ 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'))
def debug(what):
sys.stderr.write(str(what) + "\n")
return what
+def errormsg(msg):
+ """Intended for end-user-visible error messages.
+
+ (Currently just writes to stderr with an appended newline, but could do
+ something better in future: e.g. could add markup to distinguish error
+ messages from status messages or debugging output.)
+
+ Note that this should always be combined with translation:
+
+ import gettext
+ _ = gettext.gettext
+ ...
+ inkex.errormsg(_("This extension requires two selected paths."))
+ """
+ sys.stderr.write(str(msg) + "\n")
+ return what
+
def check_inkbool(option, opt, value):
if str(value).capitalize() == 'True':
return True
try:
retval = self.document.xpath(path, namespaces=NSS)[0]
except:
- debug("No matching node for expression: %s" % path)
+ errormsg(_("No matching node for expression: %s") % path)
retval = None
return retval
index 11fa77d0fe007bfc1a6244bf122c215f08bc7d28..7408b08d657b8c48f118a32ceaf7a1fcce353de4 100644 (file)
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'''
import random, inkex, simplestyle, copy
+import gettext
+_ = gettext.gettext
class MyEffect(inkex.Effect):
def __init__(self):
try:
style = simplestyle.parseStyle(node.get('style'))
except:
- inkex.debug("No style attribute found for id: %s" % id)
+ inkex.errormsg(_("No style attribute found for id: %s") % id)
continue
stroke = style.get('stroke', '#000000')
else:
mnode = old_mnode
except:
- inkex.debug("unable to locate marker: %s" % marker_id)
+ inkex.errormsg(_("unable to locate marker: %s") % marker_id)
continue
new_id = self.uniqueId(marker_id, not self.options.modify)
index 917bc665b910b6b3a157b16c2927ba70d2208d1e..f8a8a2c325ce5fed8de4126aad8c155e31242bc3 100644 (file)
import inkex, cubicsuperpath, bezmisc
import pathmodifier,simpletransform
-
import copy, math, re, random
+import gettext
+_ = gettext.gettext
def flipxy(path):
for pathcomp in path:
def effect(self):
if len(self.options.ids)<2:
- inkex.debug("This extension requires that you select two paths.")
+ inkex.errormsg(_("This extension requires two selected paths."))
return
self.prepareSelectionList()
self.options.wave = (self.options.kind=="Ribbon")
index 645b7fb6cf934530871a5630be1923d111154d59..e30ec51977d9840eb6bd08225296604553d45bd4 100644 (file)
import inkex, cubicsuperpath, bezmisc, simplestyle
from simpletransform import *
import copy, math, re, random
+import gettext
+_ = gettext.gettext
####################################################################
##-- zOrder computation...
newNode = self.unlinkClone(node,doReplace)
return self.objectToPath(newNode,doReplace)
else:
- inkex.debug("Please first convert objects to paths!...(got '%s')"%node.tag)
+ inkex.errormsg(_("Please first convert objects to paths! (Got <%s>.)") % node.tag)
return None
def objectsToPaths(self,aList,doReplace=True):
index 20623de6a794fd9fdec29e474f46a3ddbe106937..03da822c514a2822a7c796e952384a4641cfe027 100644 (file)
import inkex, cubicsuperpath, bezmisc
import pathmodifier, simpletransform
from lxml import etree
-
import copy, math, re, random
+import gettext
+_ = gettext.gettext
def zSort(inNode,idList):
sortedList=[]
def effect(self):
if len(self.options.ids)<2:
- inkex.debug("This extension requires that you select two paths.")
+ inkex.errormsg(_("This extension requires two selected paths."))
return
self.prepareSelectionList()
s+=dx
self.patternNode.getparent().remove(self.patternNode)
-
if __name__ == '__main__':
e = PathScatter()
e.affect()
-
+
# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99
index 53b1a9149174c1e52ce4f3dfae4ea3319558006d..6cd917e2239ba55c9f071da7fa01674e7f6c5345 100755 (executable)
Perspective approach & math by Dmitry Platonov, shadowjack@mail.ru, 2006
"""
import sys, inkex, os, re, simplepath, cubicsuperpath
+import gettext
+_ = gettext.gettext
from ffgeom import *
try:
from numpy import *
from numpy.linalg import *
except:
- inkex.debug("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.")
+ 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."))
sys.exit()
uuconv = {'in':90.0, 'pt':1.25, 'px':1, 'mm':3.5433070866, 'cm':35.433070866, 'pc':15.0}
inkex.Effect.__init__(self)
def effect(self):
if len(self.options.ids) < 2:
- inkex.debug("Requires two selected paths. The second must be exactly four nodes long.")
+ inkex.errormsg(_("This extension requires two selected paths."))
sys.exit()
#obj is selected second
envelope = self.selected[self.options.ids[1]]
if (obj.tag == inkex.addNS('path','svg') or obj.tag == inkex.addNS('g','svg')) and envelope.tag == inkex.addNS('path','svg'):
path = cubicsuperpath.parsePath(envelope.get('d'))
+ if len(path) < 1 or len(path[0]) < 4:
+ inkex.errormsg(_("This extension requires that the second selected path be four nodes long."))
+ sys.exit()
dp = zeros((4,2), dtype=float64)
for i in range(4):
dp[i][0] = path[0][i][1][0]
file = self.args[-1]
id = self.options.ids[0]
for query in q.keys():
- _,f,err = os.popen3('inkscape --query-%s --query-id=%s "%s"' % (query,id,file))
+ f,err = os.popen3('inkscape --query-%s --query-id=%s "%s"' % (query,id,file))[1:]
q[query] = float(f.read())
f.close()
err.close()
index 006d16d6b5813b29acb457565904691abd29f90d..fca66b1137612766df3e1a83bfe8878b5df17e76 100644 (file)
import inkex
import simplestyle, sys, simplepath, re
from math import *
+import gettext
+_ = gettext.gettext
try:
from numpy import *
except:
- inkex.debug("Failed to import the numpy module. This module is 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.")
+ inkex.errormsg(_("Failed to import the numpy module. This module is 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."))
sys.exit()
def objfile(name):
index f3d9811c4f2e19f233e783c227a710e6b31147ff..86da134b94eb4d6e86ecc3b2f8cf0039193486fb 100755 (executable)
"""
import inkex, os, simplepath, cubicsuperpath
from ffgeom import *
+import gettext
+_ = gettext.gettext
class Project(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
def effect(self):
if len(self.options.ids) < 2:
- inkex.debug("Requires two selected paths. The second must be exactly four nodes long.")
- exit()
+ inkex.errormsg(_("This extension requires two selected paths.")
+ + " "
+ + _("The second path must be exactly four nodes long."))
+ exit()
#obj is selected second
obj = self.selected[self.options.ids[0]]
file = self.args[-1]
id = self.options.ids[0]
for query in self.q.keys():
- _,f,err = os.popen3('inkscape --query-%s --query-id=%s "%s"' % (query,id,file))
+ f,err = os.popen3('inkscape --query-%s --query-id=%s "%s"' % (query,id,file))[1:]
self.q[query] = float(f.read())
f.close()
err.close()
diff --git a/share/extensions/svg_and_media_zip_output.py b/share/extensions/svg_and_media_zip_output.py
index 001d5b0f8a77600715cdf74d8d299ec7215cf3e3..e34f01749199fa62cda3c6cb6b965c5701844932 100644 (file)
import shutil
import sys
import tempfile
+import gettext
+_ = gettext.gettext
class MyEffect(inkex.Effect):
def __init__(self):
shutil.copy(tmp_dir + os.path.sep + absref,tmp_dir)
z.write(tmp_dir + os.path.sep + absref.encode("latin-1"),os.path.basename(absref).encode("latin-1"))
else:
- inkex.debug('Could not locate file: %s' % absref)
+ inkex.errormsg(_('Could not locate file: %s') % absref)
node.set(inkex.addNS('href',u'xlink'),os.path.basename(absref))
node.set(inkex.addNS('absref',u'sodipodi'),os.path.basename(absref))