Merge lp:~jpakkane/geis/python3-preparation into lp:geis

Proposed by Jussi Pakkanen on 2012-03-30
Status: Merged
Merged at revision: 285
Proposed branch: lp:~jpakkane/geis/python3-preparation
Merge into: lp:geis
Diff against target: 251 lines (+40/-24)
8 files modified
python/geis/__init__.py (+3/-0)
python/geis/geis_v2.py (+5/-3)
python/pygeis (+16/-15)
tools/geisview/classview.py (+2/-0)
tools/geisview/deviceview.py (+2/-0)
tools/geisview/filter_definition.py (+2/-0)
tools/geisview/filter_list.py (+2/-0)
tools/geisview/geisview (+8/-6)
To merge this branch: bzr merge lp:~jpakkane/geis/python3-preparation
Reviewer Review Type Date Requested Status
Stephen M. Webb (community) Approve on 2012-09-06
Chase Douglas (community) Abstain on 2012-09-06
Daniel d'Andrada (community) 2012-03-30 Needs Information on 2012-09-06
Review via email: mp+100139@code.launchpad.net

Description of the Change

Add __future__ imports for stricter compliancy in preparation for Python 3.

I would probably hold off on merging this until after 12/04.

Unicode literals are not yet implemented, because they will be a lot more work. I will either push them here (if this branch is not merged immediately) or create a new branch.

To post a comment you must log in.
239. By Jussi Pakkanen on 2012-04-02

Switched to Unicode literals to prepare for Python 3.

Jussi Pakkanen (jpakkane) wrote :

Added unicode literals. Surprisingly it did not require any actual code changes. Geisview works fine. I recommend thorough testing before merging this, though. There may be corner cases I did not catch.

Daniel d'Andrada (dandrader) wrote :

It's been a while. Do we still want it in? Seems harmless enough...

review: Needs Information
Chase Douglas (chasedouglas) wrote :

I remember Stephen had reviewed a python3 branch at one point, and he had some concerns. I would ask him to comment. I don't know enough about python to properly review this.

Alternatively, we could seek the advice of someone who knows python well.

review: Abstain
Stephen M. Webb (bregma) wrote :

This should definitely go in.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'python/geis/__init__.py'
2--- python/geis/__init__.py 2012-03-30 13:43:10 +0000
3+++ python/geis/__init__.py 2012-04-02 07:59:19 +0000
4@@ -14,9 +14,12 @@
5 # along with this program; if not, write to the Free Software
6 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
7
8+from __future__ import print_function, absolute_import, unicode_literals
9+
10 """Python bindings for the GEIS gesture recognition interface.
11 """
12
13+
14 __all__ = (
15 'Geis', 'Event', 'Filter', 'Subscription',
16 'NoMoreEvents',
17
18=== modified file 'python/geis/geis_v2.py'
19--- python/geis/geis_v2.py 2011-10-18 20:43:58 +0000
20+++ python/geis/geis_v2.py 2012-04-02 07:59:19 +0000
21@@ -14,6 +14,8 @@
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24
25+from __future__ import print_function, absolute_import, unicode_literals
26+
27 """Python bindings for the GEIS v2 gesture recognition interface.
28
29 Do not use this module directly -- the public API is provided by the 'geis'
30@@ -126,7 +128,7 @@
31 _geis_frame_touchid = _geis_lib.geis_frame_touchid
32
33 except AttributeError as ex:
34- print ex
35+ print(ex)
36 sys.exit(1)
37
38
39@@ -369,7 +371,7 @@
40
41
42 def _pointer_type_unknown(attr):
43- print "unknown pointer type", _geis_attr_name(attr)
44+ print("unknown pointer type " + _geis_attr_name(attr))
45 return None
46
47
48@@ -416,7 +418,7 @@
49
50
51 def _attr_type_unknown(attr):
52- print "unknown attr type", _geis_attr_name(attr)
53+ print("unknown attr type" + _geis_attr_name(attr))
54 return None
55
56
57
58=== modified file 'python/pygeis'
59--- python/pygeis 2012-02-23 19:42:24 +0000
60+++ python/pygeis 2012-04-02 07:59:19 +0000
61@@ -18,6 +18,7 @@
62 # You should have received a copy of the GNU General Public License
63 # along with this program. If not, see <http://www.gnu.org/licenses/>.
64 #
65+from __future__ import print_function, absolute_import, unicode_literals
66
67 import argparse
68 import geis
69@@ -28,39 +29,39 @@
70 def _print_gesture(attrs):
71 touchset = attrs[geis.GEIS_EVENT_ATTRIBUTE_TOUCHSET]
72 groupset = attrs[geis.GEIS_EVENT_ATTRIBUTE_GROUPSET]
73- print " touches (" + str(len(touchset)) + "):"
74+ print(" touches (" + str(len(touchset)) + "):")
75 for touch in touchset:
76- print " ", touch.id(), touch.attrs()
77- print " groups:"
78+ print(" ", touch.id(), touch.attrs())
79+ print(" groups:")
80 for group in groupset:
81- print " ", group.id(), ":"
82+ print(" ", group.id(), ":")
83 for frame in group:
84- print " frame ", frame.id(), ":"
85+ print(" frame ", frame.id(), ":")
86 for (k, v) in frame.attrs().iteritems():
87- print " " + k + ":", v
88- print " touches: ", frame.touches()
89+ print(" " + k + ":", v)
90+ print(" touches: ", frame.touches())
91
92 def _do_init_complete(event, sub):
93- print "init complete"
94+ print("init complete")
95 sub.activate()
96
97 def _do_device_available(event, sub):
98- print "device available"
99+ print("device available")
100
101 def _do_gesture_begin(event, sub):
102- print "gesture begin"
103+ print("gesture begin")
104 _print_gesture(event.attrs())
105
106 def _do_gesture_update(event, sub):
107- print "gesture update"
108+ print("gesture update")
109 _print_gesture(event.attrs())
110
111 def _do_gesture_end(event, sub):
112- print "gesture end"
113+ print("gesture end")
114 _print_gesture(event.attrs())
115
116 def _do_other_event(event, sub):
117- print "unknown geis event received"
118+ print("unknown geis event received")
119
120 _geis_event_action = {
121 geis.GEIS_EVENT_INIT_COMPLETE: _do_init_complete,
122@@ -90,7 +91,7 @@
123 if event.type() == geis.GEIS_EVENT_CLASS_AVAILABLE:
124 gclass = event.attrs()[geis.GEIS_EVENT_ATTRIBUTE_CLASS]
125 name = gclass.name()
126- print ".. adding class %s" % name
127+ print(".. adding class %s" % name)
128 filt = geis.Filter(g, name)
129 filt.add_term(geis.GEIS_FILTER_CLASS,
130 (geis.GEIS_CLASS_ATTRIBUTE_NAME, geis.GEIS_FILTER_OP_EQ, name),
131@@ -115,7 +116,7 @@
132 try:
133 options.parse_args()
134 except argparse.ArgumentError, ex:
135- print ex
136+ print(ex)
137 sys.exit(1)
138
139 g = geis.Geis(geis.GEIS_INIT_TRACK_DEVICES,
140
141=== modified file 'tools/geisview/classview.py'
142--- tools/geisview/classview.py 2011-07-01 14:42:42 +0000
143+++ tools/geisview/classview.py 2012-04-02 07:59:19 +0000
144@@ -18,6 +18,8 @@
145 # along with this program. If not, see <http://www.gnu.org/licenses/>.
146 #
147
148+from __future__ import print_function, absolute_import, unicode_literals
149+
150 import pygtk
151 pygtk.require('2.0')
152 import gtk
153
154=== modified file 'tools/geisview/deviceview.py'
155--- tools/geisview/deviceview.py 2011-07-01 14:42:42 +0000
156+++ tools/geisview/deviceview.py 2012-04-02 07:59:19 +0000
157@@ -18,6 +18,8 @@
158 # along with this program. If not, see <http://www.gnu.org/licenses/>.
159 #
160
161+from __future__ import print_function, absolute_import, unicode_literals
162+
163 import pygtk
164 pygtk.require('2.0')
165 import gtk
166
167=== modified file 'tools/geisview/filter_definition.py'
168--- tools/geisview/filter_definition.py 2011-05-18 13:32:13 +0000
169+++ tools/geisview/filter_definition.py 2012-04-02 07:59:19 +0000
170@@ -18,6 +18,8 @@
171 # along with this program. If not, see <http://www.gnu.org/licenses/>.
172 #
173
174+from __future__ import print_function, absolute_import, unicode_literals
175+
176 import geis
177 import geisview.defaults
178 import os
179
180=== modified file 'tools/geisview/filter_list.py'
181--- tools/geisview/filter_list.py 2011-05-18 13:32:13 +0000
182+++ tools/geisview/filter_list.py 2012-04-02 07:59:19 +0000
183@@ -18,6 +18,8 @@
184 # along with this program. If not, see <http://www.gnu.org/licenses/>.
185 #
186
187+from __future__ import print_function, absolute_import, unicode_literals
188+
189 import geisview.defaults
190 import geisview.filter_definition
191 import os
192
193=== modified file 'tools/geisview/geisview'
194--- tools/geisview/geisview 2012-01-26 19:40:29 +0000
195+++ tools/geisview/geisview 2012-04-02 07:59:19 +0000
196@@ -22,6 +22,8 @@
197 # along with this program. If not, see <http://www.gnu.org/licenses/>.
198 #
199
200+from __future__ import print_function, absolute_import, unicode_literals
201+
202 import argparse
203 import geis
204 import geisview.defaults
205@@ -92,7 +94,7 @@
206 self._main_window.show()
207
208 def _subscribe(self):
209- print "creating subscription"
210+ print("creating subscription")
211 filt = geis.Filter(self._geis, "> 1 touch")
212 filt.add_term(geis.GEIS_FILTER_CLASS,
213 (geis.GEIS_GESTURE_ATTRIBUTE_TOUCHES,
214@@ -109,16 +111,16 @@
215 gtk.main_quit()
216
217 def on_menu_item_save(self, widget, data=None):
218- print "on_menu_item_save"
219+ print("on_menu_item_save")
220
221 def on_menu_item_save_as(self, widget, data=None):
222- print "on_menu_item_save_as"
223+ print("on_menu_item_save_as")
224
225 def on_edit_clear_events_menu_item(self, widget, data=None):
226 self._geis_event_store.clear()
227
228 def on_edit_filters_menu_item_activate(self, widget, data=None):
229- print "on_edit_filters_menu_item_activate"
230+ print("on_edit_filters_menu_item_activate")
231 filter_list_dialog = geisview.filter_list.FilterList()
232 filter_list_dialog.run()
233
234@@ -176,7 +178,7 @@
235 self._geis_event_store.append(frame_row, [touch_label, None, None])
236
237 if dev:
238- print "device %s extents %s" % (dev.id(), dev.extents())
239+ print("device %s extents %s" % (dev.id(), dev.extents()))
240
241
242 def _detail_gesture(self, event_row, attrs):
243@@ -300,7 +302,7 @@
244 if args.windowid:
245 windowid = int(args.windowid, 0)
246 except argparse.ArgumentError, ex:
247- print ex
248+ print(ex)
249 sys.exit(1)
250
251 geis_viewer = GeisViewer(args)

Subscribers

People subscribed via source and target branches