diff --git a/plug-ins/pygimp/plug-ins/benchmark-foreground-extract.py b/plug-ins/pygimp/plug-ins/benchmark-foreground-extract.py index 74ecd513c4..11dfeadca2 100755 --- a/plug-ins/pygimp/plug-ins/benchmark-foreground-extract.py +++ b/plug-ins/pygimp/plug-ins/benchmark-foreground-extract.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Foreground Extraction Benchmark # Copyright 2005 Sven Neumann @@ -79,22 +79,22 @@ def benchmark (folder, save_output): mask_layer = mask.active_layer; truth = pdb.gimp_file_load (truth_name, truth_name) - convert_grayscale (truth) + convert_grayscale (truth) truth_layer = truth.active_layer; unclassified = unclassified_pixels (mask_layer, truth_layer) sys.stderr.write (os.path.basename (image_name)) - start = time.time () + start = time.time () pdb.gimp_drawable_foreground_extract (image_layer, - FOREGROUND_EXTRACT_SIOX, - mask_layer) - end = time.time () + FOREGROUND_EXTRACT_SIOX, + mask_layer) + end = time.time () sys.stderr.write (" ") - mask_layer.flush () + mask_layer.flush () # Ignore errors when creating image displays; # allows us to be used without a display. @@ -112,38 +112,38 @@ def benchmark (folder, save_output): misclassified = misclassified_pixels (mask_layer, truth_layer) sys.stderr.write ("%d %d %.2f%% %.3fs\n" % - (unclassified, misclassified, - (misclassified * 100.0 / unclassified), - end - start)) + (unclassified, misclassified, + (misclassified * 100.0 / unclassified), + end - start)) - total_unclassified += unclassified - total_misclassified += misclassified - total_time += end - start + total_unclassified += unclassified + total_misclassified += misclassified + total_time += end - start gimp.delete (truth) - if save_output: - filename = os.path.join (folder, "output", name + '.png') - pdb.gimp_file_save (mask, mask_layer, filename, filename) + if save_output: + filename = os.path.join (folder, "output", name + '.png') + pdb.gimp_file_save (mask, mask_layer, filename, filename) gimp.delete (mask) # for loop ends try: - gimp.delete (image_display) - gimp.delete (mask_display) + gimp.delete (image_display) + gimp.delete (mask_display) except UnboundLocalError: - pass + pass sys.stderr.write ("Total: %d %d %.2f%% %.3fs\n" % - (total_unclassified, total_misclassified, - (total_misclassified * 100.0 / total_unclassified), - total_time)) + (total_unclassified, total_misclassified, + (total_misclassified * 100.0 / total_unclassified), + total_time)) def convert_grayscale (image): if image.base_type != GRAY: - pdb.gimp_image_convert_grayscale (image) + pdb.gimp_image_convert_grayscale (image) def unclassified_pixels (mask, truth): @@ -174,7 +174,7 @@ def misclassified_pixels (mask, truth): (mean, std_dev, median, pixels, count, percentile) = pdb.gimp_histogram (image.flatten (), - HISTOGRAM_VALUE, 255, 255) + HISTOGRAM_VALUE, 255, 255) return count diff --git a/plug-ins/pygimp/plug-ins/clothify.py b/plug-ins/pygimp/plug-ins/clothify.py index e28645095d..1c7f973b62 100755 --- a/plug-ins/pygimp/plug-ins/clothify.py +++ b/plug-ins/pygimp/plug-ins/clothify.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Gimp-Python - allows the writing of Gimp plugins in Python. # Copyright (C) 1997 James Henstridge diff --git a/plug-ins/pygimp/plug-ins/colorxhtml.py b/plug-ins/pygimp/plug-ins/colorxhtml.py index d9c329f0be..7dc1e4714f 100755 --- a/plug-ins/pygimp/plug-ins/colorxhtml.py +++ b/plug-ins/pygimp/plug-ins/colorxhtml.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Gimp-Python - allows the writing of Gimp plugins in Python. # Copyright (C) 2003, 2005 Manish Singh @@ -58,7 +58,7 @@ preamble = """\n\n\n""" def colorxhtml(img, drawable, filename, raw_filename, - source_type, characters, size, separate): + source_type, characters, size, separate): width = drawable.width height = drawable.height bpp = drawable.bpp diff --git a/plug-ins/pygimp/plug-ins/file-openraster.py b/plug-ins/pygimp/plug-ins/file-openraster.py index 55b3a94ede..586356f37d 100755 --- a/plug-ins/pygimp/plug-ins/file-openraster.py +++ b/plug-ins/pygimp/plug-ins/file-openraster.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # GIMP Plug-in for the OpenRaster file format # http://create.freedesktop.org/wiki/OpenRaster diff --git a/plug-ins/pygimp/plug-ins/foggify.py b/plug-ins/pygimp/plug-ins/foggify.py index 60a4378aa8..84c24d3ed8 100755 --- a/plug-ins/pygimp/plug-ins/foggify.py +++ b/plug-ins/pygimp/plug-ins/foggify.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Gimp-Python - allows the writing of Gimp plugins in Python. # Copyright (C) 1997 James Henstridge diff --git a/plug-ins/pygimp/plug-ins/histogram-export.py b/plug-ins/pygimp/plug-ins/histogram-export.py index 90d7cea07f..fb24ecf250 100755 --- a/plug-ins/pygimp/plug-ins/histogram-export.py +++ b/plug-ins/pygimp/plug-ins/histogram-export.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 #coding: utf-8 # diff --git a/plug-ins/pygimp/plug-ins/palette-offset.py b/plug-ins/pygimp/plug-ins/palette-offset.py index 9f8847f030..f6895700e3 100644 --- a/plug-ins/pygimp/plug-ins/palette-offset.py +++ b/plug-ins/pygimp/plug-ins/palette-offset.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # -*- coding: utf-8 -*- # 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 diff --git a/plug-ins/pygimp/plug-ins/palette-sort.py b/plug-ins/pygimp/plug-ins/palette-sort.py index c504940f72..accc4be6ef 100644 --- a/plug-ins/pygimp/plug-ins/palette-sort.py +++ b/plug-ins/pygimp/plug-ins/palette-sort.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # -*- coding: utf-8 -*- # # This program is free software: you can redistribute it and/or modify diff --git a/plug-ins/pygimp/plug-ins/palette-to-gradient.py b/plug-ins/pygimp/plug-ins/palette-to-gradient.py index 5f6d6d53ed..d71be900f3 100644 --- a/plug-ins/pygimp/plug-ins/palette-to-gradient.py +++ b/plug-ins/pygimp/plug-ins/palette-to-gradient.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # # 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 diff --git a/plug-ins/pygimp/plug-ins/py-slice.py b/plug-ins/pygimp/plug-ins/py-slice.py index c4f198f4ee..35bad87f25 100755 --- a/plug-ins/pygimp/plug-ins/py-slice.py +++ b/plug-ins/pygimp/plug-ins/py-slice.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # -*- coding: utf-8 -*- #Copyright (c) Manish Singh diff --git a/plug-ins/pygimp/plug-ins/python-console.py b/plug-ins/pygimp/plug-ins/python-console.py index 88aa318ce9..f90ccec792 100755 --- a/plug-ins/pygimp/plug-ins/python-console.py +++ b/plug-ins/pygimp/plug-ins/python-console.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Gimp-Python - allows the writing of Gimp plugins in Python. # Copyright (C) 1997 James Henstridge diff --git a/plug-ins/pygimp/plug-ins/python-eval.py b/plug-ins/pygimp/plug-ins/python-eval.py index 1b82ebd148..22e154a652 100755 --- a/plug-ins/pygimp/plug-ins/python-eval.py +++ b/plug-ins/pygimp/plug-ins/python-eval.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Gimp-Python - allows the writing of Gimp plugins in Python. # Copyright (C) 2006 Manish Singh diff --git a/plug-ins/pygimp/plug-ins/shadow_bevel.py b/plug-ins/pygimp/plug-ins/shadow_bevel.py index 475fc988df..7d7c2a746a 100755 --- a/plug-ins/pygimp/plug-ins/shadow_bevel.py +++ b/plug-ins/pygimp/plug-ins/shadow_bevel.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Gimp-Python - allows the writing of Gimp plugins in Python. # Copyright (C) 1997 James Henstridge diff --git a/plug-ins/pygimp/plug-ins/sphere.py b/plug-ins/pygimp/plug-ins/sphere.py index b947feca1d..639aa2ad3b 100755 --- a/plug-ins/pygimp/plug-ins/sphere.py +++ b/plug-ins/pygimp/plug-ins/sphere.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Gimp-Python - allows the writing of Gimp plugins in Python. # Copyright (C) 1997 James Henstridge diff --git a/plug-ins/pygimp/plug-ins/whirlpinch.py b/plug-ins/pygimp/plug-ins/whirlpinch.py index f9df9558a0..e7f0871d48 100755 --- a/plug-ins/pygimp/plug-ins/whirlpinch.py +++ b/plug-ins/pygimp/plug-ins/whirlpinch.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Gimp-Python - allows the writing of Gimp plugins in Python. # Copyright (C) 1997 James Henstridge @@ -119,8 +119,8 @@ def whirl_pinch(image, drawable, whirl, pinch, radius): bot_p = '' for col in range(self.sel_x1, self.sel_x2): q, cx, cy = calc_undistorted_coords(self, col, - row, whirl, pinch, - radius) + row, whirl, pinch, + radius) if q: if cx >= 0: ix = int(cx) else: ix = -(int(-cx) + 1) diff --git a/plug-ins/pygimp/py-compile b/plug-ins/pygimp/py-compile index b60649de66..3448c719dd 100755 --- a/plug-ins/pygimp/py-compile +++ b/plug-ins/pygimp/py-compile @@ -2,7 +2,12 @@ # called as "py-compile [--basedir DIR] PY_FILES ... if [ -z "$PYTHON" ]; then - PYTHON=python + if [[ -x "$(command -v python2)" ]]; then + PYTHON=python2 + else + # Let's hope it's Python2 + PYTHON=python + fi fi basedir= @@ -65,4 +70,3 @@ for file in string.split(files): sys.stdout.flush() py_compile.compile(path) print" 2>/dev/null || : - diff --git a/tools/defcheck.py b/tools/defcheck.py index b029b982f0..7d80066cb4 100755 --- a/tools/defcheck.py +++ b/tools/defcheck.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ defcheck.py -- Consistency check for the .def files. diff --git a/tools/gimppath2svg.py b/tools/gimppath2svg.py index d2728b5fd7..68fe0f1051 100755 --- a/tools/gimppath2svg.py +++ b/tools/gimppath2svg.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 import sys,re @@ -50,51 +50,51 @@ class Path: def readgimpfile (self, filedesc): text = filedesc.readlines() for line in text: - namematch = re.match ("Name: (.*)$", line) - if namematch: - path.name = namematch.group(1) - pointmatch = re.match ("TYPE: (\d) X: (\d+) Y: (\d+)", line) - if pointmatch: - if pointmatch.group (1) == "3": - path.gimppoints.append ([]) - (x, y) = map (int, pointmatch.groups()[1:]) - path.gimppoints[-1].append (map (int, pointmatch.groups())) - if self.bounds: - if self.bounds[0] > x: self.bounds[0] = x - if self.bounds[1] > y: self.bounds[1] = y - if self.bounds[2] < x: self.bounds[2] = x - if self.bounds[3] < y: self.bounds[3] = y - else: - self.bounds = [x,y,x,y] + namematch = re.match ("Name: (.*)$", line) + if namematch: + path.name = namematch.group(1) + pointmatch = re.match ("TYPE: (\d) X: (\d+) Y: (\d+)", line) + if pointmatch: + if pointmatch.group (1) == "3": + path.gimppoints.append ([]) + (x, y) = map (int, pointmatch.groups()[1:]) + path.gimppoints[-1].append (map (int, pointmatch.groups())) + if self.bounds: + if self.bounds[0] > x: self.bounds[0] = x + if self.bounds[1] > y: self.bounds[1] = y + if self.bounds[2] < x: self.bounds[2] = x + if self.bounds[3] < y: self.bounds[3] = y + else: + self.bounds = [x,y,x,y] def makesvg (self): for path in self.gimppoints: if path: - start = path[0] - svg = "M %d %d " % tuple (start[1:]) - path = path[1:] - while path: - curve = path [0:3] - path = path[3:] - if len (curve) == 2: - svg = svg + "C %d %d %d %d %d %d z " % tuple ( - tuple (curve [0][1:]) + - tuple (curve [1][1:]) + - tuple (start [1:])) - if len (curve) == 3: - svg = svg + "C %d %d %d %d %d %d " % tuple ( - tuple (curve [0][1:]) + - tuple (curve [1][1:]) + - tuple (curve [2][1:])) - self.svgpath = self.svgpath + svg + start = path[0] + svg = "M %d %d " % tuple (start[1:]) + path = path[1:] + while path: + curve = path [0:3] + path = path[3:] + if len (curve) == 2: + svg = svg + "C %d %d %d %d %d %d z " % tuple ( + tuple (curve [0][1:]) + + tuple (curve [1][1:]) + + tuple (start [1:])) + if len (curve) == 3: + svg = svg + "C %d %d %d %d %d %d " % tuple ( + tuple (curve [0][1:]) + + tuple (curve [1][1:]) + + tuple (curve [2][1:])) + self.svgpath = self.svgpath + svg def writesvgfile (self, outfile): if self.svgpath: - svg = svgtemplate % (self.bounds[2]-self.bounds[0], - self.bounds[3]-self.bounds[1], - self.name, - -self.bounds[0], -self.bounds[1], - self.svgpath) + svg = svgtemplate % (self.bounds[2]-self.bounds[0], + self.bounds[3]-self.bounds[1], + self.name, + -self.bounds[0], -self.bounds[1], + self.svgpath) else: svg = emptysvgtemplate outfile.write (svg) @@ -115,4 +115,3 @@ path = Path() path.readgimpfile (infile) path.makesvg() path.writesvgfile (outfile) - diff --git a/tools/module-dependencies.py b/tools/module-dependencies.py index 54f5975b08..bccca2ca65 100755 --- a/tools/module-dependencies.py +++ b/tools/module-dependencies.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ module-dependencies.py -- GIMP library and core module dependency constructor @@ -24,18 +24,18 @@ with dependencies between GIMP library and core modules. Run it from the source root. Note that you'll either need the very latest PyGraphViz binding or use this hack in agraph.py: ---- agraph.py.orig 2010-01-04 16:07:46.000000000 +0100 -+++ agraph.py 2010-01-04 16:13:54.000000000 +0100 +--- agraph.py.orig 2010-01-04 16:07:46.000000000 +0100 ++++ agraph.py 2010-01-04 16:13:54.000000000 +0100 @@ -1154,7 +1154,8 @@ class AGraph(object): raise IOError("".join(errors)) - + if len(errors)>0: - raise IOError("".join(errors)) + # Workaround exception throwing due to warning about cycles + pass return "".join(data) - - + + """