[mousetrap/gnome3-wip] Python 2to3 conversion for 2.7 Compatable code using 2to3 tool.
- From: Heidi Ellis <heidiellis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mousetrap/gnome3-wip] Python 2to3 conversion for 2.7 Compatable code using 2to3 tool.
- Date: Wed, 18 Sep 2013 13:10:14 +0000 (UTC)
commit f979f751797eb120149927b37c316527b374a8fe
Author: Logan Hotchkiss <lhotchkiss17 gmail com>
Date: Sat Jul 6 00:57:17 2013 -0400
Python 2to3 conversion for 2.7 Compatable code using 2to3 tool.
src/mousetrap/app/addons/handler.py | 2 +-
src/mousetrap/app/lib/httpd.py | 2 +-
src/mousetrap/app/lib/settings.py | 4 +-
src/mousetrap/app/main.py | 50 +++++++++++++-------------
src/mousetrap/app/ui/dialogs.py | 8 ++--
src/mousetrap/app/ui/main.py | 9 +++--
src/mousetrap/app/ui/settings_gui.py | 7 ++--
src/mousetrap/ocvfw/_ocv.py | 8 +++-
src/mousetrap/ocvfw/backends/OcvfwCtypes.py | 2 +-
src/mousetrap/ocvfw/backends/OcvfwPython.py | 2 +-
src/mousetrap/ocvfw/commons.py | 2 +-
src/mousetrap/ocvfw/dev/camera.py | 2 +-
src/mousetrap/ocvfw/idm/color.py | 2 +-
src/mousetrap/ocvfw/pocv.py | 2 +-
14 files changed, 55 insertions(+), 47 deletions(-)
---
diff --git a/src/mousetrap/app/addons/handler.py b/src/mousetrap/app/addons/handler.py
index aa97c8b..7eba1ce 100644
--- a/src/mousetrap/app/addons/handler.py
+++ b/src/mousetrap/app/addons/handler.py
@@ -62,7 +62,7 @@ class AddonsHandler(object):
return { "name" : tmp.a_name, "dsc" : tmp.a_description, "stgs" : tmp.a_settings}
except:
- print("Problems loading mousetrap.app.addons.%s" % addon)
+ print(("Problems loading mousetrap.app.addons.%s" % addon))
class AddonsBase(object):
diff --git a/src/mousetrap/app/lib/httpd.py b/src/mousetrap/app/lib/httpd.py
index dc63cac..f26949d 100644
--- a/src/mousetrap/app/lib/httpd.py
+++ b/src/mousetrap/app/lib/httpd.py
@@ -28,7 +28,7 @@ __date__ = "$Date$"
__copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
__license__ = "GPLv2"
-import mouse
+from . import mouse
import thread
import BaseHTTPServer
diff --git a/src/mousetrap/app/lib/settings.py b/src/mousetrap/app/lib/settings.py
index 52f2d7d..2e41d87 100644
--- a/src/mousetrap/app/lib/settings.py
+++ b/src/mousetrap/app/lib/settings.py
@@ -28,10 +28,10 @@ __copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
__license__ = "GPLv2"
import os
-import ConfigParser
+import ConfigParser as configparser #FIXME should be configparser
import mousetrap.app.environment as env
-class Settings( ConfigParser.ConfigParser ):
+class Settings( configparser.ConfigParser ):
def optionxform( self, optionstr ):
"""
diff --git a/src/mousetrap/app/main.py b/src/mousetrap/app/main.py
index 6239a01..93d855b 100644
--- a/src/mousetrap/app/main.py
+++ b/src/mousetrap/app/main.py
@@ -36,18 +36,18 @@ __license__ = "GPLv2"
import sys
sys.argv[0] = "mousetrap"
-import gobject
-import debug
+from gi.repository import GObject
+from . import debug
import getopt
-import environment as env
+from . import environment as env
from mousetrap.ocvfw import pocv
-from ui.i18n import _
-from ui.main import MainGui
-from ui.scripts import get_script_class
+from .ui.i18n import _
+from .ui.main import MainGui
+from .ui.scripts import get_script_class
-from lib import httpd, dbusd, settings
+from .lib import httpd, dbusd, settings
class Controller():
"""
@@ -103,7 +103,7 @@ class Controller():
self.itf.load_addons()
if conf_created:
- from ui import settings_gui
+ from .ui import settings_gui
settings_gui.showPreffGui(self)
debug.info("mousetrap", "MouseTrap's Interface Built and Loaded")
@@ -161,7 +161,7 @@ class Controller():
self.quit(2)
if opt in ("-v", "--version"):
- print(env.version)
+ print((env.version))
self.quit(0)
# This will show the usage of mouseTrap
@@ -169,8 +169,8 @@ class Controller():
self.usage()
self.quit(0)
- except getopt.GetoptError, err:
- print str(err)
+ except getopt.GetoptError as err:
+ print(str(err))
self.usage()
self.quit(2)
pass
@@ -183,41 +183,41 @@ class Controller():
- self: The main object pointer
"""
- print( _("Usage: mouseTrap [OPTION...]"))
+ print(( _("Usage: mouseTrap [OPTION...]")))
# '-?, --help' that is used to display usage information.
#
- print( "-?, -h, --help " + \
- _(" Show this help message"))
+ print(( "-?, -h, --help " + \
+ _(" Show this help message")))
# Option:
# '-i' that is used to set the input camera index. E.g: -i 0
- print( "-s, --set " + \
- _(" Sets new value to Non Boolean options E.g -s inputDevIndex-1"))
+ print(( "-s, --set " + \
+ _(" Sets new value to Non Boolean options E.g -s inputDevIndex-1")))
# Options:
# -e, --enable Allow the users to enable modules not permantly
- print( "-e, --enable=[" \
+ print(( "-e, --enable=[" \
+ "main-window" + "|" \
- + "cam") + "]",
+ + "cam") + "]")
- print( _(" Enable the selected options"))
+ print(( _(" Enable the selected options")))
# Options:
# -d, --disable Allow the users to disable modules not permanently.
- print( "-d, --disable=[" \
+ print(( "-d, --disable=[" \
+ "main-window" + "|" \
- + "cam" + "]"),
+ + "cam" + "]"))
- print( _(" Disable the selected options"))
+ print(( _(" Disable the selected options")))
# Options:
# -t --timeout To change the mouse timeout not permanently.
- print( "-v, --version " + \
- _(" Shows mouseTrap version"))
+ print(( "-v, --version " + \
+ _(" Shows mouseTrap version")))
- print( _("\nReport bugs to flaper87 flaper87 org"))
+ print(( _("\nReport bugs to flaper87 flaper87 org")))
def script(self):
"""
diff --git a/src/mousetrap/app/ui/dialogs.py b/src/mousetrap/app/ui/dialogs.py
index dfc494e..c99e4e9 100644
--- a/src/mousetrap/app/ui/dialogs.py
+++ b/src/mousetrap/app/ui/dialogs.py
@@ -26,8 +26,8 @@ __date__ = "$Date$"
__copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
__license__ = "GPLv2"
-import gtk
-from i18n import _
+from gi.repository import Gtk
+from .i18n import _
def addLabelMessage( dialog, message ):
"""
@@ -385,11 +385,11 @@ class IdmSettings(gtk.Window):
# # We'll change the click panel position to be sure that
# # it won't appear under another window or worse under a
# # popup menu.
-# if poss[0] in xrange( env.screen["width"]/2 ):
+# if poss[0] in range( env.screen["width"]/2 ):
# X = env.screen["width"] - self.width
#
#
-# if poss[1] in xrange( env.screen["height"]/2 ):
+# if poss[1] in range( env.screen["height"]/2 ):
# Y = env.screen["height"] - self.height
#
#
diff --git a/src/mousetrap/app/ui/main.py b/src/mousetrap/app/ui/main.py
index fe08c2e..e29fbdc 100644
--- a/src/mousetrap/app/ui/main.py
+++ b/src/mousetrap/app/ui/main.py
@@ -27,9 +27,12 @@ __date__ = "$Date$"
__copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
__license__ = "GPLv2"
-import gtk
-import dialogs
-import settings_gui
+from gi.repository import Gdk
+from gi.repository import GObject
+from gi.repository import Gtk
+from gi.repository import GdkPixbuf
+from . import dialogs
+from . import settings_gui
import mousetrap.app.debug as debug
import mousetrap.app.environment as env
from mousetrap.app.addons import cpu
diff --git a/src/mousetrap/app/ui/settings_gui.py b/src/mousetrap/app/ui/settings_gui.py
index 82d961a..9b012e7 100644
--- a/src/mousetrap/app/ui/settings_gui.py
+++ b/src/mousetrap/app/ui/settings_gui.py
@@ -27,9 +27,10 @@ __date__ = "$Date$"
__copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
__license__ = "GPLv2"
-import gtk
-import dialogs
-from i18n import _
+from gi.repository import GObject
+from gi.repository import Gtk
+from . import dialogs
+from .i18n import _
from mousetrap.ocvfw import pocv
import mousetrap.app.environment as env
diff --git a/src/mousetrap/ocvfw/_ocv.py b/src/mousetrap/ocvfw/_ocv.py
index 97288c0..bd9daa8 100644
--- a/src/mousetrap/ocvfw/_ocv.py
+++ b/src/mousetrap/ocvfw/_ocv.py
@@ -27,8 +27,12 @@ __copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
__license__ = "GPLv2"
import time
-import debug
-import commons as co
+from . import debug
+from . import commons as co
+import cv2 #remove
+import cv2.cv as cv
+import numpy
+import array
class OcvfwBase:
diff --git a/src/mousetrap/ocvfw/backends/OcvfwCtypes.py b/src/mousetrap/ocvfw/backends/OcvfwCtypes.py
index 46b61ee..e84fec6 100644
--- a/src/mousetrap/ocvfw/backends/OcvfwCtypes.py
+++ b/src/mousetrap/ocvfw/backends/OcvfwCtypes.py
@@ -28,7 +28,7 @@ __license__ = "GPLv2"
import time
-from OcvfwBase import OcvfwBase
+from .OcvfwBase import OcvfwBase
from .. import debug
from .. import commons as co
diff --git a/src/mousetrap/ocvfw/backends/OcvfwPython.py b/src/mousetrap/ocvfw/backends/OcvfwPython.py
index 069143e..0cc5344 100644
--- a/src/mousetrap/ocvfw/backends/OcvfwPython.py
+++ b/src/mousetrap/ocvfw/backends/OcvfwPython.py
@@ -27,7 +27,7 @@ __copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
__license__ = "GPLv2"
import time
-from OcvfwBase import OcvfwBase
+from .OcvfwBase import OcvfwBase
from .. import debug
from .. import commons as co
diff --git a/src/mousetrap/ocvfw/commons.py b/src/mousetrap/ocvfw/commons.py
index 159d6de..566376c 100644
--- a/src/mousetrap/ocvfw/commons.py
+++ b/src/mousetrap/ocvfw/commons.py
@@ -27,7 +27,7 @@ __copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
__license__ = "GPLv2"
import os
-import debug
+from . import debug
abs_path = os.path.abspath(os.path.dirname(__file__))
diff --git a/src/mousetrap/ocvfw/dev/camera.py b/src/mousetrap/ocvfw/dev/camera.py
index a3395ac..7d00a23 100644
--- a/src/mousetrap/ocvfw/dev/camera.py
+++ b/src/mousetrap/ocvfw/dev/camera.py
@@ -80,7 +80,7 @@ class Capture(object):
self.__image_orig = None
color_vars = [x for x in dir(co.cv) if '2' in x and str(getattr(co.cv, x)).isdigit()]
- self.__color_int = dict(zip([x.lower() for x in color_vars], [getattr(co.cv,x) for x in
color_vars]))
+ self.__color_int = dict(list(zip([x.lower() for x in color_vars], [getattr(co.cv,x) for x in
color_vars])))
self.roi = None
diff --git a/src/mousetrap/ocvfw/idm/color.py b/src/mousetrap/ocvfw/idm/color.py
index bd2b8d1..e884885 100644
--- a/src/mousetrap/ocvfw/idm/color.py
+++ b/src/mousetrap/ocvfw/idm/color.py
@@ -285,7 +285,7 @@ class Module(object):
co.cv.cvConvertScale( hbins, hbins, 255. / max_val if max_val else 0., 0 )
co.cv.cvZero( self.histimg )
bin_w = self.histimg.width / self.hdims
- for i in xrange(self.hdims):
+ for i in range(self.hdims):
val = co.cv.cvRound( co.cv.cvGetReal1D(hbins,i)*self.histimg.height/255 )
color = self.hsv2rgb(i*180./self.hdims) co.cv.cvRectangle( self.histimg,
co.cv.cvPoint(i*bin_w,self.histimg.height),
co.cv.cvPoint((i+1)*bin_w,self.histimg.height - val),
diff --git a/src/mousetrap/ocvfw/pocv.py b/src/mousetrap/ocvfw/pocv.py
index fb89041..fa73fc5 100644
--- a/src/mousetrap/ocvfw/pocv.py
+++ b/src/mousetrap/ocvfw/pocv.py
@@ -55,5 +55,5 @@ def get_idm_inf(idm):
[''])
return { "name" : tmp.a_name, "dsc" : tmp.a_description, "stgs" : tmp.a_settings}
except:
- print("Problems loading mousetrap.ocvfw.idm.%s" % idm)
+ print(("Problems loading mousetrap.ocvfw.idm.%s" % idm))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]