Merge lp:~stgraber/ubuntu/quantal/newt/python3 into lp:ubuntu/quantal/newt

Proposed by Stéphane Graber
Status: Merged
Merged at revision: 44
Proposed branch: lp:~stgraber/ubuntu/quantal/newt/python3
Merge into: lp:ubuntu/quantal/newt
Diff against target: 769 lines (+651/-14)
4 files modified
debian/changelog (+17/-0)
debian/control (+29/-7)
debian/patches/002_python3.patch (+529/-0)
debian/rules (+76/-7)
To merge this branch: bzr merge lp:~stgraber/ubuntu/quantal/newt/python3
Reviewer Review Type Date Requested Status
Steve Langasek Needs Fixing
Review via email: mp+110154@code.launchpad.net
To post a comment you must log in.
50. By Stéphane Graber

Fix Provides/Depends for python3 package

51. By Stéphane Graber

Fix typo s/built a text UI/build a text UI/g

52. By Stéphane Graber

No need to send .keys() through list() as it already returns something we can iterate

Revision history for this message
Steve Langasek (vorlon) wrote :

-for n in hotkeys.keys():
+for n in list(hotkeys.keys()):

Seems unnecessary in this case? I think this is the one Colin already reported on IRC.

- if (what.__dict__.has_key('g')):
+ if ('g' in what.__dict__):

non-idiomatic parentheses, should be dropped (as should the ones three lines above; probably not worth scrubbing all of them, but as long as we're already editing this line...)

- if (type(blist) == types.StringType):
+ if (isinstance(blist, str if sys.version >= '3' else basestring)):

there's also a 'types' import that's no longer needed as a result of this change and should be dropped. (reported by pyflakes)

- if (type(item) == types.TupleType):
+ if (type(item) == tuple):

not sure if it matters to use isinstance() here?

- if (type(e) in types.StringTypes):
+ if (type(e) in str):

doesn't this one break python2 compat? Seems like this needs the same kind of 'basestring' casing based on python version that's used elsewhere.

review: Needs Fixing
53. By Stéphane Graber

.keys() is iterable, no need to get it through list()

54. By Stéphane Graber

Remove non-idiomatic parentheses

55. By Stéphane Graber

Rebuild diff, drop import of types in snack.py (no longer used) and use isinstance() instead of direct type comparison

56. By Stéphane Graber

Re-introduce list() call around hotkeys.keys() as it's actually required with python3

57. By Stéphane Graber

Do the same str or basestring trick for the other isinstance() call

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2012-02-09 16:19:14 +0000
+++ debian/changelog 2012-06-13 21:24:19 +0000
@@ -1,3 +1,20 @@
1newt (0.52.11-2ubuntu11) UNRELEASED; urgency=low
2
3 [ James Hunt ]
4 * Port python module to python3:
5 - Introduces python3-newt and python3-newt-dbg.
6 - Update build-depend to require python3-all-dev.
7
8 [ Stéphane Graber ]
9 * Port python module to python3:
10 - Make a debian/patches patch out of James' changes.
11 - Add missing python3-all-dbg build-dependency.
12 - Fix debian/rules generated symlinks to work with the python3
13 packages.
14 - Fix the Provides and Depends of the python3 packages.
15
16 -- Stéphane Graber <stgraber@ubuntu.com> Wed, 13 Jun 2012 15:53:48 -0400
17
1newt (0.52.11-2ubuntu10) precise; urgency=low18newt (0.52.11-2ubuntu10) precise; urgency=low
219
3 * Move libnewt to /lib and whiptail to /bin so they can be used by20 * Move libnewt to /lib and whiptail to /bin so they can be used by
421
=== modified file 'debian/control'
--- debian/control 2011-06-27 11:59:01 +0000
+++ debian/control 2012-06-13 21:24:19 +0000
@@ -6,7 +6,9 @@
6Standards-Version: 3.9.16Standards-Version: 3.9.1
7Homepage: https://fedorahosted.org/newt/7Homepage: https://fedorahosted.org/newt/
8Vcs-Git: git://git.fedorahosted.org/git/newt8Vcs-Git: git://git.fedorahosted.org/git/newt
9Build-Depends: dbs, sgmltools-lite, libslang2-dev (>=2.0.4-2), libpopt-dev, debhelper (>=5.0.37.2), gettext, libfribidi-dev, tcl8.5-dev, python-all-dev (>= 2.6.6-3~), autoconf, python-all-dbg9Build-Depends: dbs, sgmltools-lite, libslang2-dev (>=2.0.4-2), libpopt-dev, debhelper (>=5.0.37.2), gettext, libfribidi-dev, tcl8.5-dev, python-all-dev (>= 2.6.6-3~), python3-all-dev (>= 3.2.3), autoconf, python-all-dbg, python3-all-dbg
10X-Python-Version: >= 2.6
11X-Python3-Version: >= 3.2
1012
11Package: libnewt-dev13Package: libnewt-dev
12Architecture: any14Architecture: any
@@ -48,7 +50,7 @@
48Provides: ${python:Provides}50Provides: ${python:Provides}
49Depends: libnewt0.52 (=${binary:Version}) , ${python:Depends}, ${misc:Depends}, ${shlibs:Depends}51Depends: libnewt0.52 (=${binary:Version}) , ${python:Depends}, ${misc:Depends}, ${shlibs:Depends}
50Description: A NEWT module for Python52Description: A NEWT module for Python
51 This module allows you to built a text UI for your Python scripts53 This module allows you to build a text UI for your Python scripts
52 using newt.54 using newt.
5355
54Package: python-newt-dbg56Package: python-newt-dbg
@@ -57,11 +59,31 @@
57Priority: extra59Priority: extra
58Depends: libnewt0.52 (=${binary:Version}), python-newt (=${binary:Version}), python-dbg, ${misc:Depends}, ${shlibs:Depends}60Depends: libnewt0.52 (=${binary:Version}), python-newt (=${binary:Version}), python-dbg, ${misc:Depends}, ${shlibs:Depends}
59Description: A NEWT module for Python (debug extension)61Description: A NEWT module for Python (debug extension)
60 This module allows you to built a text UI for your Python scripts62 This module allows you to build a text UI for your Python scripts
61 using newt.63 using newt.
62 .64 .
63 This package contains the extension built for the Python debug interpreter.65 This package contains the extension built for the Python debug interpreter.
6466
67Package: python3-newt
68Architecture: any
69Section: python
70Priority: optional
71Provides: ${python3:Provides}
72Depends: libnewt0.52 (=${binary:Version}) , ${python3:Depends}, ${misc:Depends}, ${shlibs:Depends}
73Description: A NEWT module for Python 3
74 This module allows you to build a text UI for your Python 3 scripts
75 using newt.
76
77Package: python3-newt-dbg
78Architecture: any
79Section: debug
80Priority: extra
81Depends: libnewt0.52 (=${binary:Version}), python3-newt (=${binary:Version}), python3-dbg, ${misc:Depends}, ${shlibs:Depends}
82Description: A NEWT module for Python 3 (debug extension)
83 This module allows you to build a text UI for your Python 3 scripts
84 using newt.
85 .
86 This package contains the extension built for the Python debug interpreter.
6587
66Package: libnewt0.5288Package: libnewt0.52
67Architecture: any89Architecture: any
6890
=== added file 'debian/patches/002_python3.patch'
--- debian/patches/002_python3.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/002_python3.patch 2012-06-13 21:24:19 +0000
@@ -0,0 +1,529 @@
1diff -Nrup newt-0.52.11.orig/Makefile.in newt-0.52.11/Makefile.in
2--- newt-0.52.11.orig/Makefile.in 2012-06-13 15:27:07.475835745 -0400
3+++ newt-0.52.11/Makefile.in 2012-06-13 16:48:33.031972016 -0400
4@@ -12,6 +12,7 @@ TAG = r$(subst .,-,$(VERSION))
5 SONAME = @SONAME@
6
7 PYTHONVERS = $(shell pyversions --supported)
8+PYTHON3VERS = $(shell py3versions --supported)
9 WHIPTCLSO = @WHIPTCLSO@
10
11 PROGS = test whiptail $(WHIPTCLSO) testgrid testtree showchars showkey
12@@ -68,7 +69,7 @@ showkey: showkey.o $(LIBNEWT)
13 $(CC) -g -o showkey showkey.o $(LIBNEWT) $(LIBS)
14
15 _snackmodule.so: snackmodule.c $(LIBNEWTSH)
16- for ver in $(PYTHONVERS) ; do \
17+ for ver in $(PYTHONVERS) $(PYTHON3VERS); do \
18 mkdir -p $$ver ;\
19 $(CC) $(CFLAGS) -I/usr/include/$$ver $(SHCFLAGS) -c -o $$ver/snackmodule.o snackmodule.c ;\
20 $(CC) --shared $(SHCFLAGS) -o $$ver/_snackmodule.so $$ver/snackmodule.o -L . -lnewt ;\
21@@ -129,7 +130,7 @@ install-sh: sharedlib $(WHIPTCLSO) _snac
22 ln -sf $(LIBNEWTSONAME) $(instroot)/$(libdir)/libnewt.so
23 ln -sf $(LIBNEWTSH) $(instroot)/$(libdir)/$(LIBNEWTSONAME)
24 [ -n "$(WHIPTCLSO)" ] && install -m 755 whiptcl.so $(instroot)/$(libdir) || :
25- for ver in $(PYTHONVERS) ; do \
26+ for ver in $(PYTHONVERS) $(PYTHON3VERS); do \
27 [ -d $(instroot)/$(libdir)/$$ver/site-packages ] || install -m 755 -d $(instroot)/$(libdir)/$$ver/site-packages ;\
28 install -m 755 $$ver/_snackmodule.so $(instroot)/$(libdir)/$$ver/site-packages ;\
29 + install -m 755 $$ver/_snackmodule_d.so $(instroot)/$(libdir)/$$ver/site-packages ;\
30diff -Nrup newt-0.52.11.orig/peanuts.py newt-0.52.11/peanuts.py
31--- newt-0.52.11.orig/peanuts.py 2009-09-24 11:03:09.000000000 -0400
32+++ newt-0.52.11/peanuts.py 2012-06-13 16:48:33.031972016 -0400
33@@ -2,6 +2,7 @@
34
35 # Demo program to show use of python-newt module
36
37+from __future__ import absolute_import, print_function, unicode_literals
38 from snack import *
39
40 screen = SnackScreen()
41@@ -38,8 +39,8 @@ result = g.runOnce()
42
43 screen.finish()
44
45-print result
46-print "listbox:", li.current()
47-print "rb:", rb.getSelection()
48-print "bb:", bb.buttonPressed(result)
49-print "checkboxtree:", ct.getSelection()
50+print(result)
51+print("listbox:", li.current())
52+print("rb:", rb.getSelection())
53+print("bb:", bb.buttonPressed(result))
54+print("checkboxtree:", ct.getSelection())
55diff -Nrup newt-0.52.11.orig/popcorn.py newt-0.52.11/popcorn.py
56--- newt-0.52.11.orig/popcorn.py 2009-09-24 11:03:09.000000000 -0400
57+++ newt-0.52.11/popcorn.py 2012-06-13 16:48:33.031972016 -0400
58@@ -1,5 +1,6 @@
59 #!/usr/bin/python
60
61+from __future__ import absolute_import, print_function, unicode_literals
62 from snack import *
63 import sys
64
65@@ -45,7 +46,7 @@ r1 = SingleRadioButton("Radio 1", None,
66 r2 = SingleRadioButton("Radio 2", r1)
67
68 def something():
69- print hello
70+ print(hello)
71
72 screen = SnackScreen()
73
74@@ -99,14 +100,14 @@ g.runOnce()
75
76 screen.finish()
77
78-print "val", e.value()
79-print "check", cb.value()
80-print "r1", r1.selected()
81-print "listbox", li.current()
82+print("val", e.value())
83+print("check", cb.value())
84+print("r1", r1.selected())
85+print("listbox", li.current())
86 # returns a tuple of the wrapped text, the actual width, and the actual height
87-print res
88+print(res)
89
90-print foo
91-print 'lbcw', lbcw
92-print "ct selected", ct.getSelection()
93-print "ct current", ct.getCurrent()
94+print(foo)
95+print('lbcw', lbcw)
96+print("ct selected", ct.getSelection())
97+print("ct current", ct.getCurrent())
98diff -Nrup newt-0.52.11.orig/snackmodule.c newt-0.52.11/snackmodule.c
99--- newt-0.52.11.orig/snackmodule.c 2012-06-13 15:27:07.479835744 -0400
100+++ newt-0.52.11/snackmodule.c 2012-06-13 16:48:33.031972016 -0400
101@@ -12,10 +12,24 @@
102 #include <unistd.h>
103
104 #include "Python.h"
105+#include "structmember.h"
106 #include "nls.h"
107 #include "newt.h"
108 #include "newt_pr.h"
109
110+#if PY_MAJOR_VERSION >= 3
111+ #define PyInt_FromLong PyLong_FromLong
112+ #define PyInt_AsLong PyLong_AsLong
113+ #define PyString_FromString PyUnicode_FromString
114+ #define MOD_ERROR_VAL NULL
115+ #define MOD_SUCCESS_VAL(val) val
116+ #define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void)
117+#else
118+ #define MOD_ERROR_VAL
119+ #define MOD_SUCCESS_VAL(val)
120+ #define MOD_INIT(name) void init##name(void)
121+#endif
122+
123 typedef struct snackWidget_s snackWidget;
124 typedef struct snackGrid_s snackGrid;
125 typedef struct snackForm_s snackForm;
126@@ -68,6 +82,8 @@ static snackWidget * textWidget(PyObject
127 static PyObject * ternaryWindow(PyObject * s, PyObject * args);
128 static snackWidget * checkboxTreeWidget(PyObject * s, PyObject * args, PyObject * kwargs);
129 static PyObject * pywstrlen(PyObject * s, PyObject * args);
130+static PyObject * widget_get_checkboxValue(PyObject *self, void *closure);
131+static PyObject * widget_get_radioValue(PyObject *self, void *closure);
132
133 static PyMethodDef snackModuleMethods[] = {
134 { "button", (PyCFunction) buttonWidget, METH_VARARGS, NULL },
135@@ -107,12 +123,31 @@ static PyMethodDef snackModuleMethods[]
136 { NULL }
137 } ;
138
139+#if PY_MAJOR_VERSION >= 3
140+static struct PyModuleDef moduledef = {
141+ PyModuleDef_HEAD_INIT,
142+ "_snack", /* m_name */
143+ NULL, /* m_doc */
144+ -1, /* m_size */
145+ snackModuleMethods, /* m_methods */
146+ NULL, /* m_reload */
147+ NULL, /* m_traverse */
148+ NULL, /* m_clear */
149+ NULL, /* m_free */
150+ };
151+#endif
152+
153+static struct PyGetSetDef widget_getset[] = {
154+ { "checkboxValue", widget_get_checkboxValue, 0, NULL, NULL },
155+ { "radioValue", widget_get_radioValue, 0, NULL, NULL },
156+ { NULL }
157+};
158+
159 struct snackGrid_s {
160 PyObject_HEAD
161 newtGrid grid;
162 } ;
163
164-static PyObject * gridGetAttr(PyObject * s, char * name);
165 static PyObject * gridPlace(snackGrid * s, PyObject * args);
166 static PyObject * gridSetField(snackGrid * s, PyObject * args);
167
168@@ -123,20 +158,34 @@ static PyMethodDef gridMethods[] = {
169 };
170
171 static PyTypeObject snackGridType = {
172- PyObject_HEAD_INIT(&PyType_Type)
173- 0, /* ob_size */
174+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
175 "snackgrid", /* tp_name */
176 sizeof(snackGrid), /* tp_size */
177 0, /* tp_itemsize */
178 emptyDestructor, /* tp_dealloc */
179 0, /* tp_print */
180- gridGetAttr, /* tp_getattr */
181+ 0, /* tp_getattr */
182 0, /* tp_setattr */
183 0, /* tp_compare */
184 0, /* tp_repr */
185 0, /* tp_as_number */
186 0, /* tp_as_sequence */
187 0, /* tp_as_mapping */
188+ 0, /* tp_hash */
189+ 0, /* tp_call */
190+ 0, /* tp_str */
191+ PyObject_GenericGetAttr, /* tp_getattro */
192+ 0, /* tp_setattro */
193+ 0, /* tp_as_buffer */
194+ Py_TPFLAGS_DEFAULT, /* tp_flags */
195+ 0, /* tp_doc */
196+ 0, /* tp_traverse */
197+ 0, /* tp_clear */
198+ 0, /* tp_richcompare */
199+ 0, /* tp_weaklistoffset */
200+ 0, /* tp_iter */
201+ 0, /* tp_iternext */
202+ gridMethods /* tp_methods */
203 };
204
205 struct snackForm_s {
206@@ -144,7 +193,6 @@ struct snackForm_s {
207 newtComponent fo;
208 } ;
209
210-static PyObject * formGetAttr(PyObject * s, char * name);
211 static PyObject * formAdd(snackForm * s, PyObject * args);
212 static PyObject * formDraw(snackForm * s, PyObject * args);
213 static PyObject * formRun(snackForm * s, PyObject * args);
214@@ -165,20 +213,34 @@ static PyMethodDef formMethods[] = {
215 };
216
217 static PyTypeObject snackFormType = {
218- PyObject_HEAD_INIT(&PyType_Type)
219- 0, /* ob_size */
220+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
221 "snackform", /* tp_name */
222 sizeof(snackForm), /* tp_size */
223 0, /* tp_itemsize */
224 emptyDestructor, /* tp_dealloc */
225 0, /* tp_print */
226- formGetAttr, /* tp_getattr */
227+ 0, /* tp_getattr */
228 0, /* tp_setattr */
229 0, /* tp_compare */
230 0, /* tp_repr */
231 0, /* tp_as_number */
232 0, /* tp_as_sequence */
233 0, /* tp_as_mapping */
234+ 0, /* tp_hash */
235+ 0, /* tp_call */
236+ 0, /* tp_str */
237+ PyObject_GenericGetAttr, /* tp_getattro */
238+ 0, /* tp_setattro */
239+ 0, /* tp_as_buffer */
240+ Py_TPFLAGS_DEFAULT, /* tp_flags */
241+ 0, /* tp_doc */
242+ 0, /* tp_traverse */
243+ 0, /* tp_clear */
244+ 0, /* tp_richcompare */
245+ 0, /* tp_weaklistoffset */
246+ 0, /* tp_iter */
247+ 0, /* tp_iternext */
248+ formMethods /* tp_methods */
249 };
250
251 struct snackWidget_s {
252@@ -191,7 +253,6 @@ struct snackWidget_s {
253 } ;
254
255 static PyObject * widgetAddCallback(snackWidget * s, PyObject * args);
256-static PyObject * widgetGetAttr(PyObject * s, char * name);
257 static void widgetDestructor(PyObject * s);
258 static PyObject * widgetEntrySetValue(snackWidget * s, PyObject * args);
259 static PyObject * widgetLabelText(snackWidget * s, PyObject * args);
260@@ -253,21 +314,43 @@ static PyMethodDef widgetMethods[] = {
261 { NULL }
262 };
263
264+static PyMemberDef widget_members[] = {
265+ { "key" , T_INT, offsetof(snackWidget, co), 0, NULL },
266+ { "entryValue", T_STRING, offsetof(snackWidget, apointer), 0, NULL },
267+ { NULL }
268+};
269+
270 static PyTypeObject snackWidgetType = {
271- PyObject_HEAD_INIT(&PyType_Type)
272- 0, /* ob_size */
273+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
274 "snackwidget", /* tp_name */
275 sizeof(snackWidget), /* tp_size */
276 0, /* tp_itemsize */
277 widgetDestructor, /* tp_dealloc */
278 0, /* tp_print */
279- widgetGetAttr, /* tp_getattr */
280+ 0, /* tp_getattr */
281 0, /* tp_setattr */
282 0, /* tp_compare */
283 0, /* tp_repr */
284 0, /* tp_as_number */
285 0, /* tp_as_sequence */
286 0, /* tp_as_mapping */
287+ 0, /* tp_hash */
288+ 0, /* tp_call */
289+ 0, /* tp_str */
290+ PyObject_GenericGetAttr, /* tp_getattro */
291+ 0, /* tp_setattro */
292+ 0, /* tp_as_buffer */
293+ Py_TPFLAGS_DEFAULT, /* tp_flags */
294+ 0, /* tp_doc */
295+ 0, /* tp_traverse */
296+ 0, /* tp_clear */
297+ 0, /* tp_richcompare */
298+ 0, /* tp_weaklistoffset */
299+ 0, /* tp_iter */
300+ 0, /* tp_iternext */
301+ widgetMethods, /* tp_methods */
302+ widget_members, /* tp_members */
303+ widget_getset /* tp_getset */
304 };
305
306 static snackWidget * snackWidgetNew (void) {
307@@ -808,10 +891,6 @@ static snackGrid * gridCreate(PyObject *
308 return grid;
309 }
310
311-static PyObject * gridGetAttr(PyObject * s, char * name) {
312- return Py_FindMethod(gridMethods, s, name);
313-}
314-
315 static PyObject * gridPlace(snackGrid * grid, PyObject * args) {
316 int x, y;
317
318@@ -835,7 +914,7 @@ static PyObject * gridSetField(snackGrid
319 &anchorFlags, &growFlags))
320 return NULL;
321
322- if (w->ob_type == &snackWidgetType) {
323+ if (Py_TYPE(w) == &snackWidgetType) {
324 newtGridSetField(grid->grid, x, y, NEWT_GRID_COMPONENT,
325 w->co, pLeft, pTop, pRight, pBottom, anchorFlags,
326 growFlags);
327@@ -850,10 +929,6 @@ static PyObject * gridSetField(snackGrid
328 return Py_None;
329 }
330
331-static PyObject * formGetAttr(PyObject * s, char * name) {
332- return Py_FindMethod(formMethods, s, name);
333-}
334-
335 static PyObject * formDraw(snackForm * s, PyObject * args) {
336 newtDrawForm(s->fo);
337
338@@ -943,20 +1018,18 @@ static PyObject * formSetCurrent(snackFo
339 return Py_None;
340 }
341
342-static PyObject * widgetGetAttr(PyObject * s, char * name) {
343- snackWidget * w = (snackWidget *) s;
344+static PyObject * widget_get_checkboxValue(PyObject *self, void *closure)
345+{
346+ snackWidget *w = (snackWidget *)self;
347
348- if (!strcmp(name, "key")) {
349- return Py_BuildValue("i", w->co);
350- } else if (!strcmp(name, "entryValue")) {
351- return Py_BuildValue("s", w->apointer);
352- } else if (!strcmp(name, "checkboxValue")) {
353 return Py_BuildValue("i", w->achar == ' ' ? 0 : 1);
354- } else if (!strcmp(name, "radioValue")) {
355- return Py_BuildValue("i", newtRadioGetCurrent(w->co));
356- }
357+}
358+
359+static PyObject * widget_get_radioValue(PyObject *self, void *closure)
360+{
361+ snackWidget *w = (snackWidget *)self;
362
363- return Py_FindMethod(widgetMethods, s, name);
364+ return Py_BuildValue("i", newtRadioGetCurrent(w->co));
365 }
366
367 static void widgetDestructor(PyObject * o) {
368@@ -1284,7 +1357,8 @@ static PyObject * pywstrlen(PyObject * s
369 return PyInt_FromLong(wstrlen(str, len));
370 }
371
372-void init_snack(void) {
373+MOD_INIT(_snack)
374+{
375 PyObject * d, * m;
376
377 #ifdef ENABLE_NLS
378@@ -1293,7 +1367,15 @@ void init_snack(void) {
379 textdomain (PACKAGE);
380 #endif
381
382+#if PY_MAJOR_VERSION >= 3
383+ m = PyModule_Create(&moduledef);
384+#else
385 m = Py_InitModule("_snack", snackModuleMethods);
386+#endif
387+
388+ if (! m)
389+ return MOD_ERROR_VAL;
390+
391 d = PyModule_GetDict(m);
392
393 PyDict_SetItemString(d, "ANCHOR_LEFT", PyInt_FromLong(NEWT_ANCHOR_LEFT));
394@@ -1355,4 +1437,6 @@ void init_snack(void) {
395 PyDict_SetItemString(d, "COLORSET_COMPACTBUTTON", PyInt_FromLong(NEWT_COLORSET_COMPACTBUTTON));
396 PyDict_SetItemString(d, "COLORSET_ACTSELLISTBOX", PyInt_FromLong(NEWT_COLORSET_ACTSELLISTBOX));
397 PyDict_SetItemString(d, "COLORSET_SELLISTBOX", PyInt_FromLong(NEWT_COLORSET_SELLISTBOX));
398+
399+ return MOD_SUCCESS_VAL(m);
400 }
401diff -Nrup newt-0.52.11.orig/snack.py newt-0.52.11/snack.py
402--- newt-0.52.11.orig/snack.py 2009-09-24 11:03:09.000000000 -0400
403+++ newt-0.52.11/snack.py 2012-06-13 17:05:17.416000032 -0400
404@@ -39,9 +39,10 @@ Functions:
405 - EntryWindow
406 """
407
408+
409+from __future__ import absolute_import, print_function, unicode_literals
410 import _snack
411-import types
412-import string
413+import sys
414
415 from _snack import FLAG_DISABLED, FLAGS_SET, FLAGS_RESET, FLAGS_TOGGLE, FD_READ, FD_WRITE, FD_EXCEPT
416
417@@ -296,7 +297,7 @@ hotkeys = { "F1" : _snack.KEY_F1, "F2" :
418 "F10" : _snack.KEY_F10, "F11" : _snack.KEY_F11,
419 "F12" : _snack.KEY_F12, "ESC" : _snack.KEY_ESC , " " : ord(" ") }
420
421-for n in hotkeys.keys():
422+for n in list(hotkeys.keys()):
423 hotkeys[hotkeys[n]] = n
424
425 class Form:
426@@ -317,14 +318,14 @@ class Form:
427 self.w.addhotkey(hotkeys[keyname])
428
429 def add(self, widget):
430- if widget.__dict__.has_key('hotkeys'):
431+ if 'hotkeys' in widget.__dict__:
432 for key in widget.hotkeys.keys():
433 self.addHotKey(key)
434
435- if widget.__dict__.has_key('gridmembers'):
436+ if 'gridmembers' in widget.__dict__:
437 for w in widget.gridmembers:
438 self.add(w)
439- elif widget.__dict__.has_key('w'):
440+ elif 'w' in widget.__dict__:
441 self.trans[widget.w.key] = widget
442 return self.w.add(widget.w)
443 return None
444@@ -397,14 +398,14 @@ class Grid:
445 if (growy):
446 gridFlags = gridFlags | _snack.GRID_GROWY
447
448- if (what.__dict__.has_key('g')):
449+ if 'g' in what.__dict__:
450 return self.g.setfield(col, row, what.g, padding, anchorFlags,
451 gridFlags)
452 else:
453 return self.g.setfield(col, row, what.w, padding, anchorFlags)
454
455 def __init__(self, *args):
456- self.g = apply(_snack.grid, args)
457+ self.g = _snack.grid(*args)
458 self.gridmembers = []
459
460 colorsets = { "ROOT" : _snack.COLORSET_ROOT,
461@@ -470,7 +471,7 @@ class SnackScreen:
462
463 def helpCallback(self, cb):
464 self.helpCb = cb
465- return _snack.helpcallback(self.doHelpCallback)
466+ return _snack.helpcallback(self.doHelpCallback)
467
468 def suspendCallback(self, cb, data = None):
469 if data:
470@@ -589,9 +590,9 @@ class ButtonBar(Grid):
471 self.item = 0
472 Grid.__init__(self, len(buttonlist), 1)
473 for blist in buttonlist:
474- if (type(blist) == types.StringType):
475+ if isinstance(blist, str if sys.version >= '3' else basestring):
476 title = blist
477- value = string.lower(blist)
478+ value = blist.lower()
479 elif len(blist) == 2:
480 (title, value) = blist
481 else:
482@@ -607,7 +608,7 @@ class ButtonBar(Grid):
483 self.item = self.item + 1
484
485 def buttonPressed(self, result):
486- if self.hotkeys.has_key(result):
487+ if result in self.hotkeys:
488 return self.hotkeys[result]
489
490 for (button, value) in self.list:
491@@ -642,7 +643,7 @@ class GridFormHelp(Grid):
492 self.form_created = 0
493 args = list(args)
494 args[:0] = [self]
495- apply(Grid.__init__, tuple(args))
496+ Grid.__init__(*tuple(args))
497
498 def add(self, widget, col, row, padding = (0, 0, 0, 0),
499 anchorLeft = 0, anchorTop = 0, anchorRight = 0,
500@@ -698,7 +699,7 @@ class GridForm(GridFormHelp):
501 """
502 def __init__(self, screen, title, *args):
503 myargs = (self, screen, title, None) + args
504- apply(GridFormHelp.__init__, myargs)
505+ GridFormHelp.__init__(*myargs)
506
507 class CheckboxTree(Widget):
508 """ CheckboxTree combo widget,
509@@ -773,7 +774,7 @@ def ListboxChoiceWindow(screen, title, t
510 l = Listbox(height, scroll = scroll, returnExit = 1)
511 count = 0
512 for item in items:
513- if (type(item) == types.TupleType):
514+ if type(item) == tuple:
515 (text, key) = item
516 else:
517 text = item
518@@ -833,9 +834,9 @@ def EntryWindow(screen, title, text, pro
519 count = 0
520 entryList = []
521 for n in prompts:
522- if (type(n) == types.TupleType):
523+ if type(n) == tuple:
524 (n, e) = n
525- if (type(e) in types.StringTypes):
526+ if isinstance(e, str if sys.version >= '3' else basestring):
527 e = Entry(entryWidth, e)
528 else:
529 e = Entry(entryWidth)
0530
=== modified file 'debian/rules'
--- debian/rules 2012-02-09 16:13:25 +0000
+++ debian/rules 2012-06-13 21:24:19 +0000
@@ -9,7 +9,6 @@
9# Uncomment this to turn on verbose mode.9# Uncomment this to turn on verbose mode.
10# export DH_VERBOSE=110# export DH_VERBOSE=1
1111
12
13DEB_HOST_GNU_TYPE=$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)12DEB_HOST_GNU_TYPE=$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
14DEB_BUILD_GNU_TYPE=$(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)13DEB_BUILD_GNU_TYPE=$(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
15ifneq ($(DEB_HOST_GNU_TYPE), $(DEB_BUILD_GNU_TYPE))14ifneq ($(DEB_HOST_GNU_TYPE), $(DEB_BUILD_GNU_TYPE))
@@ -23,6 +22,10 @@
23VERSION=0.52.1122VERSION=0.52.11
24SONAME=0.5223SONAME=0.52
25PYVERS=$(shell pyversions -vr debian/control)24PYVERS=$(shell pyversions -vr debian/control)
25PY3VERS=$(shell py3versions -vr debian/control)
26
27PYTHON2=$(shell pyversions -r debian/control)
28PYTHON3=$(shell py3versions -r debian/control)
2629
27LIB_PKG=libnewt$(SONAME)30LIB_PKG=libnewt$(SONAME)
28DEV_PKG=libnewt-dev31DEV_PKG=libnewt-dev
@@ -30,7 +33,10 @@
30TCL_PKG=newt-tcl33TCL_PKG=newt-tcl
31PYTHON_PKG=python-newt34PYTHON_PKG=python-newt
32PYTHON_DBG_PKG=python-newt-dbg35PYTHON_DBG_PKG=python-newt-dbg
36PYTHON3_PKG=python3-newt
37PYTHON3_DBG_PKG=python3-newt-dbg
33WHIPTAIL_PKG=whiptail38WHIPTAIL_PKG=whiptail
39EXAMPLES=peanuts.py popcorn.py
3440
35# the dbs rules41# the dbs rules
36TAR_DIR=newt-$(VERSION)42TAR_DIR=newt-$(VERSION)
@@ -102,14 +108,15 @@
102 dh_testroot108 dh_testroot
103 dh_clean 109 dh_clean
104 rm -rf $(SOURCE_DIR) $(STAMP_DIR)110 rm -rf $(SOURCE_DIR) $(STAMP_DIR)
105 rm -f debian/python-newt*.dirs debian/python-newt*.install debian/python-newt.postinst111 rm -f debian/python-newt*.dirs debian/python*-newt*.install debian/python-newt.postinst
112 rm -f debian/python*-newt*.examples
106 # rm -rf debian/substvars debian/*.bak debian/*~ *~ 113 # rm -rf debian/substvars debian/*.bak debian/*~ *~
107114
108binary: binary-indep binary-arch115binary: binary-indep binary-arch
109116
110binary-indep:117binary-indep:
111118
112binary-arch: $(LIB_PKG) $(DEV_PKG) $(PIC_PKG) $(TCL_PKG) $(PYTHON_PKG) $(PYTHON_DBG_PKG) $(WHIPTAIL_PKG)119binary-arch: $(LIB_PKG) $(DEV_PKG) $(PIC_PKG) $(TCL_PKG) $(PYTHON_PKG) $(PYTHON_DBG_PKG) $(PYTHON3_PKG) $(PYTHON3_DBG_PKG) $(WHIPTAIL_PKG)
113120
114$(LIB_PKG): build121$(LIB_PKG): build
115 dh_testdir122 dh_testdir
@@ -210,17 +217,22 @@
210 done217 done
211 dh_installdirs -p $@ 218 dh_installdirs -p $@
212 dh_install -p $@ --sourcedir=$(BUILD_TREE)219 dh_install -p $@ --sourcedir=$(BUILD_TREE)
213 dh_strip -p $@ --dbg-package python-newt-dbg220 dh_strip -p $@ --dbg-package $(PYTHON_DBG_PKG)
214 dh_python2 -p $@
215 dh_installdocs -p $@ $(BUILD_TREE)/newt.spec221 dh_installdocs -p $@ $(BUILD_TREE)/newt.spec
216 # Currently disabled, as debian-test has been removed.222 # Currently disabled, as debian-test has been removed.
217 # chmod +x debian/whiptail/usr/lib/debian-test/tests/whiptail/test-newt.sh/test-newt.sh223 # chmod +x debian/whiptail/usr/lib/debian-test/tests/whiptail/test-newt.sh/test-newt.sh
218 dh_installchangelogs -p $@ 224 dh_installchangelogs -p $@
225 for example in $(EXAMPLES); do \
226 echo "build-tree/*/$$example" >> debian/$@.examples; \
227 done
219 dh_installexamples -p $@228 dh_installexamples -p $@
229 sed -i "1s/^\(#! *[^ ]*\)python$\/\1$(PYTHON2)/" debian/$(@)/usr/share/doc/$(@)/examples/*.py
220 dh_compress -p $@230 dh_compress -p $@
221 dh_shlibdeps -p $@ -ldebian/$@/usr/lib231 dh_shlibdeps -p $@ -ldebian/$@/usr/lib
222 dh_fixperms -p $@232 dh_fixperms -p $@
223 dh_installdeb -p $@233 dh_installdeb -p $@
234 # Call after all other files have been created and installed
235 dh_python2 -p $@
224 dh_gencontrol -p $@ 236 dh_gencontrol -p $@
225 dh_md5sums -p $@237 dh_md5sums -p $@
226 dh_builddeb -p $@238 dh_builddeb -p $@
@@ -236,13 +248,70 @@
236 done248 done
237 dh_installdirs -p $@ 249 dh_installdirs -p $@
238 dh_install -p $@ --sourcedir=$(BUILD_TREE)250 dh_install -p $@ --sourcedir=$(BUILD_TREE)
251 mkdir -p debian/$(@)/usr/share/doc
252 ln -sf $(PYTHON_PKG) debian/$(@)/usr/share/doc/$(@)
253 dh_compress -p $@
254 dh_shlibdeps -p $@ -ldebian/$@/usr/lib
255 dh_fixperms -p $@
256 dh_installdeb -p $@
257 # Call after all other files have been created and installed
239 dh_python2 -p $@258 dh_python2 -p $@
240 mkdir -p debian/python-newt-dbg/usr/share/doc259 dh_gencontrol -p $@
241 ln -sf python-newt debian/python-newt-dbg/usr/share/doc/python-newt-dbg260 dh_md5sums -p $@
261 dh_builddeb -p $@
262
263$(PYTHON3_PKG): build
264 dh_testdir
265 dh_testroot
266 for v in $(PY3VERS); do \
267 pylib=$$(python$$v -c 'from distutils import sysconfig; print(sysconfig.get_python_lib())'); \
268 echo $$pylib >> debian/$@.dirs; \
269 echo python$$v/_snackmodule.so $$pylib/ \
270 >> debian/$@.install; \
271 echo snack.py $$pylib \
272 >> debian/$@.install; \
273 done
274 dh_installdirs -p $@
275 dh_install -p $@ --sourcedir=$(BUILD_TREE)
276 dh_strip -p $@ --dbg-package $(PYTHON3_DBG_PKG)
277 dh_installdocs -p $@ $(BUILD_TREE)/newt.spec
278 # Currently disabled, as debian-test has been removed.
279 # chmod +x debian/whiptail/usr/lib/debian-test/tests/whiptail/test-newt.sh/test-newt.sh
280 dh_installchangelogs -p $@
281 for example in $(EXAMPLES); do \
282 echo "build-tree/*/$$example" >> debian/$@.examples; \
283 done
284 dh_installexamples -p $@
285 sed -i "1s/^\(#! *[^ ]*\)python$\/\1$(PYTHON3)/" debian/$(@)/usr/share/doc/$(@)/examples/*.py
286 dh_compress -p $@
287 dh_shlibdeps -p $@ -ldebian/$@/usr/lib
288 dh_fixperms -p $@
289 dh_installdeb -p $@
290 # Call after all other files have been created and installed
291 dh_python3 -p $@
292 dh_gencontrol -p $@
293 dh_md5sums -p $@
294 dh_builddeb -p $@
295
296$(PYTHON3_DBG_PKG): build $(PYTHON3_PKG)
297 dh_testdir
298 dh_testroot
299 for v in $(PY3VERS); do \
300 pylib=$$(python$$v -c 'from distutils import sysconfig; print(sysconfig.get_python_lib(1))'); \
301 echo $$pylib >> debian/$@.dirs; \
302 echo python$$v/_snackmodule_d.so $$pylib/ \
303 >> debian/$@.install; \
304 done
305 dh_installdirs -p $@
306 dh_install -p $@ --sourcedir=$(BUILD_TREE)
307 mkdir -p debian/$(@)/usr/share/doc
308 ln -sf $(PYTHON3_PKG) debian/$(@)/usr/share/doc/$(@)
242 dh_compress -p $@309 dh_compress -p $@
243 dh_shlibdeps -p $@ -ldebian/$@/usr/lib310 dh_shlibdeps -p $@ -ldebian/$@/usr/lib
244 dh_fixperms -p $@311 dh_fixperms -p $@
245 dh_installdeb -p $@312 dh_installdeb -p $@
313 # Call after all other files have been created and installed
314 dh_python3 -p $@
246 dh_gencontrol -p $@ 315 dh_gencontrol -p $@
247 dh_md5sums -p $@316 dh_md5sums -p $@
248 dh_builddeb -p $@317 dh_builddeb -p $@

Subscribers

People subscribed via source and target branches