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
1=== modified file 'debian/changelog'
2--- debian/changelog 2012-02-09 16:19:14 +0000
3+++ debian/changelog 2012-06-13 21:24:19 +0000
4@@ -1,3 +1,20 @@
5+newt (0.52.11-2ubuntu11) UNRELEASED; urgency=low
6+
7+ [ James Hunt ]
8+ * Port python module to python3:
9+ - Introduces python3-newt and python3-newt-dbg.
10+ - Update build-depend to require python3-all-dev.
11+
12+ [ Stéphane Graber ]
13+ * Port python module to python3:
14+ - Make a debian/patches patch out of James' changes.
15+ - Add missing python3-all-dbg build-dependency.
16+ - Fix debian/rules generated symlinks to work with the python3
17+ packages.
18+ - Fix the Provides and Depends of the python3 packages.
19+
20+ -- Stéphane Graber <stgraber@ubuntu.com> Wed, 13 Jun 2012 15:53:48 -0400
21+
22 newt (0.52.11-2ubuntu10) precise; urgency=low
23
24 * Move libnewt to /lib and whiptail to /bin so they can be used by
25
26=== modified file 'debian/control'
27--- debian/control 2011-06-27 11:59:01 +0000
28+++ debian/control 2012-06-13 21:24:19 +0000
29@@ -6,7 +6,9 @@
30 Standards-Version: 3.9.1
31 Homepage: https://fedorahosted.org/newt/
32 Vcs-Git: git://git.fedorahosted.org/git/newt
33-Build-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-dbg
34+Build-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
35+X-Python-Version: >= 2.6
36+X-Python3-Version: >= 3.2
37
38 Package: libnewt-dev
39 Architecture: any
40@@ -48,7 +50,7 @@
41 Provides: ${python:Provides}
42 Depends: libnewt0.52 (=${binary:Version}) , ${python:Depends}, ${misc:Depends}, ${shlibs:Depends}
43 Description: A NEWT module for Python
44- This module allows you to built a text UI for your Python scripts
45+ This module allows you to build a text UI for your Python scripts
46 using newt.
47
48 Package: python-newt-dbg
49@@ -57,11 +59,31 @@
50 Priority: extra
51 Depends: libnewt0.52 (=${binary:Version}), python-newt (=${binary:Version}), python-dbg, ${misc:Depends}, ${shlibs:Depends}
52 Description: A NEWT module for Python (debug extension)
53- This module allows you to built a text UI for your Python scripts
54- using newt.
55- .
56- This package contains the extension built for the Python debug interpreter.
57-
58+ This module allows you to build a text UI for your Python scripts
59+ using newt.
60+ .
61+ This package contains the extension built for the Python debug interpreter.
62+
63+Package: python3-newt
64+Architecture: any
65+Section: python
66+Priority: optional
67+Provides: ${python3:Provides}
68+Depends: libnewt0.52 (=${binary:Version}) , ${python3:Depends}, ${misc:Depends}, ${shlibs:Depends}
69+Description: A NEWT module for Python 3
70+ This module allows you to build a text UI for your Python 3 scripts
71+ using newt.
72+
73+Package: python3-newt-dbg
74+Architecture: any
75+Section: debug
76+Priority: extra
77+Depends: libnewt0.52 (=${binary:Version}), python3-newt (=${binary:Version}), python3-dbg, ${misc:Depends}, ${shlibs:Depends}
78+Description: A NEWT module for Python 3 (debug extension)
79+ This module allows you to build a text UI for your Python 3 scripts
80+ using newt.
81+ .
82+ This package contains the extension built for the Python debug interpreter.
83
84 Package: libnewt0.52
85 Architecture: any
86
87=== added file 'debian/patches/002_python3.patch'
88--- debian/patches/002_python3.patch 1970-01-01 00:00:00 +0000
89+++ debian/patches/002_python3.patch 2012-06-13 21:24:19 +0000
90@@ -0,0 +1,529 @@
91+diff -Nrup newt-0.52.11.orig/Makefile.in newt-0.52.11/Makefile.in
92+--- newt-0.52.11.orig/Makefile.in 2012-06-13 15:27:07.475835745 -0400
93++++ newt-0.52.11/Makefile.in 2012-06-13 16:48:33.031972016 -0400
94+@@ -12,6 +12,7 @@ TAG = r$(subst .,-,$(VERSION))
95+ SONAME = @SONAME@
96+
97+ PYTHONVERS = $(shell pyversions --supported)
98++PYTHON3VERS = $(shell py3versions --supported)
99+ WHIPTCLSO = @WHIPTCLSO@
100+
101+ PROGS = test whiptail $(WHIPTCLSO) testgrid testtree showchars showkey
102+@@ -68,7 +69,7 @@ showkey: showkey.o $(LIBNEWT)
103+ $(CC) -g -o showkey showkey.o $(LIBNEWT) $(LIBS)
104+
105+ _snackmodule.so: snackmodule.c $(LIBNEWTSH)
106+- for ver in $(PYTHONVERS) ; do \
107++ for ver in $(PYTHONVERS) $(PYTHON3VERS); do \
108+ mkdir -p $$ver ;\
109+ $(CC) $(CFLAGS) -I/usr/include/$$ver $(SHCFLAGS) -c -o $$ver/snackmodule.o snackmodule.c ;\
110+ $(CC) --shared $(SHCFLAGS) -o $$ver/_snackmodule.so $$ver/snackmodule.o -L . -lnewt ;\
111+@@ -129,7 +130,7 @@ install-sh: sharedlib $(WHIPTCLSO) _snac
112+ ln -sf $(LIBNEWTSONAME) $(instroot)/$(libdir)/libnewt.so
113+ ln -sf $(LIBNEWTSH) $(instroot)/$(libdir)/$(LIBNEWTSONAME)
114+ [ -n "$(WHIPTCLSO)" ] && install -m 755 whiptcl.so $(instroot)/$(libdir) || :
115+- for ver in $(PYTHONVERS) ; do \
116++ for ver in $(PYTHONVERS) $(PYTHON3VERS); do \
117+ [ -d $(instroot)/$(libdir)/$$ver/site-packages ] || install -m 755 -d $(instroot)/$(libdir)/$$ver/site-packages ;\
118+ install -m 755 $$ver/_snackmodule.so $(instroot)/$(libdir)/$$ver/site-packages ;\
119+ + install -m 755 $$ver/_snackmodule_d.so $(instroot)/$(libdir)/$$ver/site-packages ;\
120+diff -Nrup newt-0.52.11.orig/peanuts.py newt-0.52.11/peanuts.py
121+--- newt-0.52.11.orig/peanuts.py 2009-09-24 11:03:09.000000000 -0400
122++++ newt-0.52.11/peanuts.py 2012-06-13 16:48:33.031972016 -0400
123+@@ -2,6 +2,7 @@
124+
125+ # Demo program to show use of python-newt module
126+
127++from __future__ import absolute_import, print_function, unicode_literals
128+ from snack import *
129+
130+ screen = SnackScreen()
131+@@ -38,8 +39,8 @@ result = g.runOnce()
132+
133+ screen.finish()
134+
135+-print result
136+-print "listbox:", li.current()
137+-print "rb:", rb.getSelection()
138+-print "bb:", bb.buttonPressed(result)
139+-print "checkboxtree:", ct.getSelection()
140++print(result)
141++print("listbox:", li.current())
142++print("rb:", rb.getSelection())
143++print("bb:", bb.buttonPressed(result))
144++print("checkboxtree:", ct.getSelection())
145+diff -Nrup newt-0.52.11.orig/popcorn.py newt-0.52.11/popcorn.py
146+--- newt-0.52.11.orig/popcorn.py 2009-09-24 11:03:09.000000000 -0400
147++++ newt-0.52.11/popcorn.py 2012-06-13 16:48:33.031972016 -0400
148+@@ -1,5 +1,6 @@
149+ #!/usr/bin/python
150+
151++from __future__ import absolute_import, print_function, unicode_literals
152+ from snack import *
153+ import sys
154+
155+@@ -45,7 +46,7 @@ r1 = SingleRadioButton("Radio 1", None,
156+ r2 = SingleRadioButton("Radio 2", r1)
157+
158+ def something():
159+- print hello
160++ print(hello)
161+
162+ screen = SnackScreen()
163+
164+@@ -99,14 +100,14 @@ g.runOnce()
165+
166+ screen.finish()
167+
168+-print "val", e.value()
169+-print "check", cb.value()
170+-print "r1", r1.selected()
171+-print "listbox", li.current()
172++print("val", e.value())
173++print("check", cb.value())
174++print("r1", r1.selected())
175++print("listbox", li.current())
176+ # returns a tuple of the wrapped text, the actual width, and the actual height
177+-print res
178++print(res)
179+
180+-print foo
181+-print 'lbcw', lbcw
182+-print "ct selected", ct.getSelection()
183+-print "ct current", ct.getCurrent()
184++print(foo)
185++print('lbcw', lbcw)
186++print("ct selected", ct.getSelection())
187++print("ct current", ct.getCurrent())
188+diff -Nrup newt-0.52.11.orig/snackmodule.c newt-0.52.11/snackmodule.c
189+--- newt-0.52.11.orig/snackmodule.c 2012-06-13 15:27:07.479835744 -0400
190++++ newt-0.52.11/snackmodule.c 2012-06-13 16:48:33.031972016 -0400
191+@@ -12,10 +12,24 @@
192+ #include <unistd.h>
193+
194+ #include "Python.h"
195++#include "structmember.h"
196+ #include "nls.h"
197+ #include "newt.h"
198+ #include "newt_pr.h"
199+
200++#if PY_MAJOR_VERSION >= 3
201++ #define PyInt_FromLong PyLong_FromLong
202++ #define PyInt_AsLong PyLong_AsLong
203++ #define PyString_FromString PyUnicode_FromString
204++ #define MOD_ERROR_VAL NULL
205++ #define MOD_SUCCESS_VAL(val) val
206++ #define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void)
207++#else
208++ #define MOD_ERROR_VAL
209++ #define MOD_SUCCESS_VAL(val)
210++ #define MOD_INIT(name) void init##name(void)
211++#endif
212++
213+ typedef struct snackWidget_s snackWidget;
214+ typedef struct snackGrid_s snackGrid;
215+ typedef struct snackForm_s snackForm;
216+@@ -68,6 +82,8 @@ static snackWidget * textWidget(PyObject
217+ static PyObject * ternaryWindow(PyObject * s, PyObject * args);
218+ static snackWidget * checkboxTreeWidget(PyObject * s, PyObject * args, PyObject * kwargs);
219+ static PyObject * pywstrlen(PyObject * s, PyObject * args);
220++static PyObject * widget_get_checkboxValue(PyObject *self, void *closure);
221++static PyObject * widget_get_radioValue(PyObject *self, void *closure);
222+
223+ static PyMethodDef snackModuleMethods[] = {
224+ { "button", (PyCFunction) buttonWidget, METH_VARARGS, NULL },
225+@@ -107,12 +123,31 @@ static PyMethodDef snackModuleMethods[]
226+ { NULL }
227+ } ;
228+
229++#if PY_MAJOR_VERSION >= 3
230++static struct PyModuleDef moduledef = {
231++ PyModuleDef_HEAD_INIT,
232++ "_snack", /* m_name */
233++ NULL, /* m_doc */
234++ -1, /* m_size */
235++ snackModuleMethods, /* m_methods */
236++ NULL, /* m_reload */
237++ NULL, /* m_traverse */
238++ NULL, /* m_clear */
239++ NULL, /* m_free */
240++ };
241++#endif
242++
243++static struct PyGetSetDef widget_getset[] = {
244++ { "checkboxValue", widget_get_checkboxValue, 0, NULL, NULL },
245++ { "radioValue", widget_get_radioValue, 0, NULL, NULL },
246++ { NULL }
247++};
248++
249+ struct snackGrid_s {
250+ PyObject_HEAD
251+ newtGrid grid;
252+ } ;
253+
254+-static PyObject * gridGetAttr(PyObject * s, char * name);
255+ static PyObject * gridPlace(snackGrid * s, PyObject * args);
256+ static PyObject * gridSetField(snackGrid * s, PyObject * args);
257+
258+@@ -123,20 +158,34 @@ static PyMethodDef gridMethods[] = {
259+ };
260+
261+ static PyTypeObject snackGridType = {
262+- PyObject_HEAD_INIT(&PyType_Type)
263+- 0, /* ob_size */
264++ PyVarObject_HEAD_INIT(&PyType_Type, 0)
265+ "snackgrid", /* tp_name */
266+ sizeof(snackGrid), /* tp_size */
267+ 0, /* tp_itemsize */
268+ emptyDestructor, /* tp_dealloc */
269+ 0, /* tp_print */
270+- gridGetAttr, /* tp_getattr */
271++ 0, /* tp_getattr */
272+ 0, /* tp_setattr */
273+ 0, /* tp_compare */
274+ 0, /* tp_repr */
275+ 0, /* tp_as_number */
276+ 0, /* tp_as_sequence */
277+ 0, /* tp_as_mapping */
278++ 0, /* tp_hash */
279++ 0, /* tp_call */
280++ 0, /* tp_str */
281++ PyObject_GenericGetAttr, /* tp_getattro */
282++ 0, /* tp_setattro */
283++ 0, /* tp_as_buffer */
284++ Py_TPFLAGS_DEFAULT, /* tp_flags */
285++ 0, /* tp_doc */
286++ 0, /* tp_traverse */
287++ 0, /* tp_clear */
288++ 0, /* tp_richcompare */
289++ 0, /* tp_weaklistoffset */
290++ 0, /* tp_iter */
291++ 0, /* tp_iternext */
292++ gridMethods /* tp_methods */
293+ };
294+
295+ struct snackForm_s {
296+@@ -144,7 +193,6 @@ struct snackForm_s {
297+ newtComponent fo;
298+ } ;
299+
300+-static PyObject * formGetAttr(PyObject * s, char * name);
301+ static PyObject * formAdd(snackForm * s, PyObject * args);
302+ static PyObject * formDraw(snackForm * s, PyObject * args);
303+ static PyObject * formRun(snackForm * s, PyObject * args);
304+@@ -165,20 +213,34 @@ static PyMethodDef formMethods[] = {
305+ };
306+
307+ static PyTypeObject snackFormType = {
308+- PyObject_HEAD_INIT(&PyType_Type)
309+- 0, /* ob_size */
310++ PyVarObject_HEAD_INIT(&PyType_Type, 0)
311+ "snackform", /* tp_name */
312+ sizeof(snackForm), /* tp_size */
313+ 0, /* tp_itemsize */
314+ emptyDestructor, /* tp_dealloc */
315+ 0, /* tp_print */
316+- formGetAttr, /* tp_getattr */
317++ 0, /* tp_getattr */
318+ 0, /* tp_setattr */
319+ 0, /* tp_compare */
320+ 0, /* tp_repr */
321+ 0, /* tp_as_number */
322+ 0, /* tp_as_sequence */
323+ 0, /* tp_as_mapping */
324++ 0, /* tp_hash */
325++ 0, /* tp_call */
326++ 0, /* tp_str */
327++ PyObject_GenericGetAttr, /* tp_getattro */
328++ 0, /* tp_setattro */
329++ 0, /* tp_as_buffer */
330++ Py_TPFLAGS_DEFAULT, /* tp_flags */
331++ 0, /* tp_doc */
332++ 0, /* tp_traverse */
333++ 0, /* tp_clear */
334++ 0, /* tp_richcompare */
335++ 0, /* tp_weaklistoffset */
336++ 0, /* tp_iter */
337++ 0, /* tp_iternext */
338++ formMethods /* tp_methods */
339+ };
340+
341+ struct snackWidget_s {
342+@@ -191,7 +253,6 @@ struct snackWidget_s {
343+ } ;
344+
345+ static PyObject * widgetAddCallback(snackWidget * s, PyObject * args);
346+-static PyObject * widgetGetAttr(PyObject * s, char * name);
347+ static void widgetDestructor(PyObject * s);
348+ static PyObject * widgetEntrySetValue(snackWidget * s, PyObject * args);
349+ static PyObject * widgetLabelText(snackWidget * s, PyObject * args);
350+@@ -253,21 +314,43 @@ static PyMethodDef widgetMethods[] = {
351+ { NULL }
352+ };
353+
354++static PyMemberDef widget_members[] = {
355++ { "key" , T_INT, offsetof(snackWidget, co), 0, NULL },
356++ { "entryValue", T_STRING, offsetof(snackWidget, apointer), 0, NULL },
357++ { NULL }
358++};
359++
360+ static PyTypeObject snackWidgetType = {
361+- PyObject_HEAD_INIT(&PyType_Type)
362+- 0, /* ob_size */
363++ PyVarObject_HEAD_INIT(&PyType_Type, 0)
364+ "snackwidget", /* tp_name */
365+ sizeof(snackWidget), /* tp_size */
366+ 0, /* tp_itemsize */
367+ widgetDestructor, /* tp_dealloc */
368+ 0, /* tp_print */
369+- widgetGetAttr, /* tp_getattr */
370++ 0, /* tp_getattr */
371+ 0, /* tp_setattr */
372+ 0, /* tp_compare */
373+ 0, /* tp_repr */
374+ 0, /* tp_as_number */
375+ 0, /* tp_as_sequence */
376+ 0, /* tp_as_mapping */
377++ 0, /* tp_hash */
378++ 0, /* tp_call */
379++ 0, /* tp_str */
380++ PyObject_GenericGetAttr, /* tp_getattro */
381++ 0, /* tp_setattro */
382++ 0, /* tp_as_buffer */
383++ Py_TPFLAGS_DEFAULT, /* tp_flags */
384++ 0, /* tp_doc */
385++ 0, /* tp_traverse */
386++ 0, /* tp_clear */
387++ 0, /* tp_richcompare */
388++ 0, /* tp_weaklistoffset */
389++ 0, /* tp_iter */
390++ 0, /* tp_iternext */
391++ widgetMethods, /* tp_methods */
392++ widget_members, /* tp_members */
393++ widget_getset /* tp_getset */
394+ };
395+
396+ static snackWidget * snackWidgetNew (void) {
397+@@ -808,10 +891,6 @@ static snackGrid * gridCreate(PyObject *
398+ return grid;
399+ }
400+
401+-static PyObject * gridGetAttr(PyObject * s, char * name) {
402+- return Py_FindMethod(gridMethods, s, name);
403+-}
404+-
405+ static PyObject * gridPlace(snackGrid * grid, PyObject * args) {
406+ int x, y;
407+
408+@@ -835,7 +914,7 @@ static PyObject * gridSetField(snackGrid
409+ &anchorFlags, &growFlags))
410+ return NULL;
411+
412+- if (w->ob_type == &snackWidgetType) {
413++ if (Py_TYPE(w) == &snackWidgetType) {
414+ newtGridSetField(grid->grid, x, y, NEWT_GRID_COMPONENT,
415+ w->co, pLeft, pTop, pRight, pBottom, anchorFlags,
416+ growFlags);
417+@@ -850,10 +929,6 @@ static PyObject * gridSetField(snackGrid
418+ return Py_None;
419+ }
420+
421+-static PyObject * formGetAttr(PyObject * s, char * name) {
422+- return Py_FindMethod(formMethods, s, name);
423+-}
424+-
425+ static PyObject * formDraw(snackForm * s, PyObject * args) {
426+ newtDrawForm(s->fo);
427+
428+@@ -943,20 +1018,18 @@ static PyObject * formSetCurrent(snackFo
429+ return Py_None;
430+ }
431+
432+-static PyObject * widgetGetAttr(PyObject * s, char * name) {
433+- snackWidget * w = (snackWidget *) s;
434++static PyObject * widget_get_checkboxValue(PyObject *self, void *closure)
435++{
436++ snackWidget *w = (snackWidget *)self;
437+
438+- if (!strcmp(name, "key")) {
439+- return Py_BuildValue("i", w->co);
440+- } else if (!strcmp(name, "entryValue")) {
441+- return Py_BuildValue("s", w->apointer);
442+- } else if (!strcmp(name, "checkboxValue")) {
443+ return Py_BuildValue("i", w->achar == ' ' ? 0 : 1);
444+- } else if (!strcmp(name, "radioValue")) {
445+- return Py_BuildValue("i", newtRadioGetCurrent(w->co));
446+- }
447++}
448++
449++static PyObject * widget_get_radioValue(PyObject *self, void *closure)
450++{
451++ snackWidget *w = (snackWidget *)self;
452+
453+- return Py_FindMethod(widgetMethods, s, name);
454++ return Py_BuildValue("i", newtRadioGetCurrent(w->co));
455+ }
456+
457+ static void widgetDestructor(PyObject * o) {
458+@@ -1284,7 +1357,8 @@ static PyObject * pywstrlen(PyObject * s
459+ return PyInt_FromLong(wstrlen(str, len));
460+ }
461+
462+-void init_snack(void) {
463++MOD_INIT(_snack)
464++{
465+ PyObject * d, * m;
466+
467+ #ifdef ENABLE_NLS
468+@@ -1293,7 +1367,15 @@ void init_snack(void) {
469+ textdomain (PACKAGE);
470+ #endif
471+
472++#if PY_MAJOR_VERSION >= 3
473++ m = PyModule_Create(&moduledef);
474++#else
475+ m = Py_InitModule("_snack", snackModuleMethods);
476++#endif
477++
478++ if (! m)
479++ return MOD_ERROR_VAL;
480++
481+ d = PyModule_GetDict(m);
482+
483+ PyDict_SetItemString(d, "ANCHOR_LEFT", PyInt_FromLong(NEWT_ANCHOR_LEFT));
484+@@ -1355,4 +1437,6 @@ void init_snack(void) {
485+ PyDict_SetItemString(d, "COLORSET_COMPACTBUTTON", PyInt_FromLong(NEWT_COLORSET_COMPACTBUTTON));
486+ PyDict_SetItemString(d, "COLORSET_ACTSELLISTBOX", PyInt_FromLong(NEWT_COLORSET_ACTSELLISTBOX));
487+ PyDict_SetItemString(d, "COLORSET_SELLISTBOX", PyInt_FromLong(NEWT_COLORSET_SELLISTBOX));
488++
489++ return MOD_SUCCESS_VAL(m);
490+ }
491+diff -Nrup newt-0.52.11.orig/snack.py newt-0.52.11/snack.py
492+--- newt-0.52.11.orig/snack.py 2009-09-24 11:03:09.000000000 -0400
493++++ newt-0.52.11/snack.py 2012-06-13 17:05:17.416000032 -0400
494+@@ -39,9 +39,10 @@ Functions:
495+ - EntryWindow
496+ """
497+
498++
499++from __future__ import absolute_import, print_function, unicode_literals
500+ import _snack
501+-import types
502+-import string
503++import sys
504+
505+ from _snack import FLAG_DISABLED, FLAGS_SET, FLAGS_RESET, FLAGS_TOGGLE, FD_READ, FD_WRITE, FD_EXCEPT
506+
507+@@ -296,7 +297,7 @@ hotkeys = { "F1" : _snack.KEY_F1, "F2" :
508+ "F10" : _snack.KEY_F10, "F11" : _snack.KEY_F11,
509+ "F12" : _snack.KEY_F12, "ESC" : _snack.KEY_ESC , " " : ord(" ") }
510+
511+-for n in hotkeys.keys():
512++for n in list(hotkeys.keys()):
513+ hotkeys[hotkeys[n]] = n
514+
515+ class Form:
516+@@ -317,14 +318,14 @@ class Form:
517+ self.w.addhotkey(hotkeys[keyname])
518+
519+ def add(self, widget):
520+- if widget.__dict__.has_key('hotkeys'):
521++ if 'hotkeys' in widget.__dict__:
522+ for key in widget.hotkeys.keys():
523+ self.addHotKey(key)
524+
525+- if widget.__dict__.has_key('gridmembers'):
526++ if 'gridmembers' in widget.__dict__:
527+ for w in widget.gridmembers:
528+ self.add(w)
529+- elif widget.__dict__.has_key('w'):
530++ elif 'w' in widget.__dict__:
531+ self.trans[widget.w.key] = widget
532+ return self.w.add(widget.w)
533+ return None
534+@@ -397,14 +398,14 @@ class Grid:
535+ if (growy):
536+ gridFlags = gridFlags | _snack.GRID_GROWY
537+
538+- if (what.__dict__.has_key('g')):
539++ if 'g' in what.__dict__:
540+ return self.g.setfield(col, row, what.g, padding, anchorFlags,
541+ gridFlags)
542+ else:
543+ return self.g.setfield(col, row, what.w, padding, anchorFlags)
544+
545+ def __init__(self, *args):
546+- self.g = apply(_snack.grid, args)
547++ self.g = _snack.grid(*args)
548+ self.gridmembers = []
549+
550+ colorsets = { "ROOT" : _snack.COLORSET_ROOT,
551+@@ -470,7 +471,7 @@ class SnackScreen:
552+
553+ def helpCallback(self, cb):
554+ self.helpCb = cb
555+- return _snack.helpcallback(self.doHelpCallback)
556++ return _snack.helpcallback(self.doHelpCallback)
557+
558+ def suspendCallback(self, cb, data = None):
559+ if data:
560+@@ -589,9 +590,9 @@ class ButtonBar(Grid):
561+ self.item = 0
562+ Grid.__init__(self, len(buttonlist), 1)
563+ for blist in buttonlist:
564+- if (type(blist) == types.StringType):
565++ if isinstance(blist, str if sys.version >= '3' else basestring):
566+ title = blist
567+- value = string.lower(blist)
568++ value = blist.lower()
569+ elif len(blist) == 2:
570+ (title, value) = blist
571+ else:
572+@@ -607,7 +608,7 @@ class ButtonBar(Grid):
573+ self.item = self.item + 1
574+
575+ def buttonPressed(self, result):
576+- if self.hotkeys.has_key(result):
577++ if result in self.hotkeys:
578+ return self.hotkeys[result]
579+
580+ for (button, value) in self.list:
581+@@ -642,7 +643,7 @@ class GridFormHelp(Grid):
582+ self.form_created = 0
583+ args = list(args)
584+ args[:0] = [self]
585+- apply(Grid.__init__, tuple(args))
586++ Grid.__init__(*tuple(args))
587+
588+ def add(self, widget, col, row, padding = (0, 0, 0, 0),
589+ anchorLeft = 0, anchorTop = 0, anchorRight = 0,
590+@@ -698,7 +699,7 @@ class GridForm(GridFormHelp):
591+ """
592+ def __init__(self, screen, title, *args):
593+ myargs = (self, screen, title, None) + args
594+- apply(GridFormHelp.__init__, myargs)
595++ GridFormHelp.__init__(*myargs)
596+
597+ class CheckboxTree(Widget):
598+ """ CheckboxTree combo widget,
599+@@ -773,7 +774,7 @@ def ListboxChoiceWindow(screen, title, t
600+ l = Listbox(height, scroll = scroll, returnExit = 1)
601+ count = 0
602+ for item in items:
603+- if (type(item) == types.TupleType):
604++ if type(item) == tuple:
605+ (text, key) = item
606+ else:
607+ text = item
608+@@ -833,9 +834,9 @@ def EntryWindow(screen, title, text, pro
609+ count = 0
610+ entryList = []
611+ for n in prompts:
612+- if (type(n) == types.TupleType):
613++ if type(n) == tuple:
614+ (n, e) = n
615+- if (type(e) in types.StringTypes):
616++ if isinstance(e, str if sys.version >= '3' else basestring):
617+ e = Entry(entryWidth, e)
618+ else:
619+ e = Entry(entryWidth)
620
621=== modified file 'debian/rules'
622--- debian/rules 2012-02-09 16:13:25 +0000
623+++ debian/rules 2012-06-13 21:24:19 +0000
624@@ -9,7 +9,6 @@
625 # Uncomment this to turn on verbose mode.
626 # export DH_VERBOSE=1
627
628-
629 DEB_HOST_GNU_TYPE=$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
630 DEB_BUILD_GNU_TYPE=$(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
631 ifneq ($(DEB_HOST_GNU_TYPE), $(DEB_BUILD_GNU_TYPE))
632@@ -23,6 +22,10 @@
633 VERSION=0.52.11
634 SONAME=0.52
635 PYVERS=$(shell pyversions -vr debian/control)
636+PY3VERS=$(shell py3versions -vr debian/control)
637+
638+PYTHON2=$(shell pyversions -r debian/control)
639+PYTHON3=$(shell py3versions -r debian/control)
640
641 LIB_PKG=libnewt$(SONAME)
642 DEV_PKG=libnewt-dev
643@@ -30,7 +33,10 @@
644 TCL_PKG=newt-tcl
645 PYTHON_PKG=python-newt
646 PYTHON_DBG_PKG=python-newt-dbg
647+PYTHON3_PKG=python3-newt
648+PYTHON3_DBG_PKG=python3-newt-dbg
649 WHIPTAIL_PKG=whiptail
650+EXAMPLES=peanuts.py popcorn.py
651
652 # the dbs rules
653 TAR_DIR=newt-$(VERSION)
654@@ -102,14 +108,15 @@
655 dh_testroot
656 dh_clean
657 rm -rf $(SOURCE_DIR) $(STAMP_DIR)
658- rm -f debian/python-newt*.dirs debian/python-newt*.install debian/python-newt.postinst
659+ rm -f debian/python-newt*.dirs debian/python*-newt*.install debian/python-newt.postinst
660+ rm -f debian/python*-newt*.examples
661 # rm -rf debian/substvars debian/*.bak debian/*~ *~
662
663 binary: binary-indep binary-arch
664
665 binary-indep:
666
667-binary-arch: $(LIB_PKG) $(DEV_PKG) $(PIC_PKG) $(TCL_PKG) $(PYTHON_PKG) $(PYTHON_DBG_PKG) $(WHIPTAIL_PKG)
668+binary-arch: $(LIB_PKG) $(DEV_PKG) $(PIC_PKG) $(TCL_PKG) $(PYTHON_PKG) $(PYTHON_DBG_PKG) $(PYTHON3_PKG) $(PYTHON3_DBG_PKG) $(WHIPTAIL_PKG)
669
670 $(LIB_PKG): build
671 dh_testdir
672@@ -210,17 +217,22 @@
673 done
674 dh_installdirs -p $@
675 dh_install -p $@ --sourcedir=$(BUILD_TREE)
676- dh_strip -p $@ --dbg-package python-newt-dbg
677- dh_python2 -p $@
678+ dh_strip -p $@ --dbg-package $(PYTHON_DBG_PKG)
679 dh_installdocs -p $@ $(BUILD_TREE)/newt.spec
680 # Currently disabled, as debian-test has been removed.
681 # chmod +x debian/whiptail/usr/lib/debian-test/tests/whiptail/test-newt.sh/test-newt.sh
682 dh_installchangelogs -p $@
683+ for example in $(EXAMPLES); do \
684+ echo "build-tree/*/$$example" >> debian/$@.examples; \
685+ done
686 dh_installexamples -p $@
687+ sed -i "1s/^\(#! *[^ ]*\)python$\/\1$(PYTHON2)/" debian/$(@)/usr/share/doc/$(@)/examples/*.py
688 dh_compress -p $@
689 dh_shlibdeps -p $@ -ldebian/$@/usr/lib
690 dh_fixperms -p $@
691 dh_installdeb -p $@
692+ # Call after all other files have been created and installed
693+ dh_python2 -p $@
694 dh_gencontrol -p $@
695 dh_md5sums -p $@
696 dh_builddeb -p $@
697@@ -236,13 +248,70 @@
698 done
699 dh_installdirs -p $@
700 dh_install -p $@ --sourcedir=$(BUILD_TREE)
701+ mkdir -p debian/$(@)/usr/share/doc
702+ ln -sf $(PYTHON_PKG) debian/$(@)/usr/share/doc/$(@)
703+ dh_compress -p $@
704+ dh_shlibdeps -p $@ -ldebian/$@/usr/lib
705+ dh_fixperms -p $@
706+ dh_installdeb -p $@
707+ # Call after all other files have been created and installed
708 dh_python2 -p $@
709- mkdir -p debian/python-newt-dbg/usr/share/doc
710- ln -sf python-newt debian/python-newt-dbg/usr/share/doc/python-newt-dbg
711+ dh_gencontrol -p $@
712+ dh_md5sums -p $@
713+ dh_builddeb -p $@
714+
715+$(PYTHON3_PKG): build
716+ dh_testdir
717+ dh_testroot
718+ for v in $(PY3VERS); do \
719+ pylib=$$(python$$v -c 'from distutils import sysconfig; print(sysconfig.get_python_lib())'); \
720+ echo $$pylib >> debian/$@.dirs; \
721+ echo python$$v/_snackmodule.so $$pylib/ \
722+ >> debian/$@.install; \
723+ echo snack.py $$pylib \
724+ >> debian/$@.install; \
725+ done
726+ dh_installdirs -p $@
727+ dh_install -p $@ --sourcedir=$(BUILD_TREE)
728+ dh_strip -p $@ --dbg-package $(PYTHON3_DBG_PKG)
729+ dh_installdocs -p $@ $(BUILD_TREE)/newt.spec
730+ # Currently disabled, as debian-test has been removed.
731+ # chmod +x debian/whiptail/usr/lib/debian-test/tests/whiptail/test-newt.sh/test-newt.sh
732+ dh_installchangelogs -p $@
733+ for example in $(EXAMPLES); do \
734+ echo "build-tree/*/$$example" >> debian/$@.examples; \
735+ done
736+ dh_installexamples -p $@
737+ sed -i "1s/^\(#! *[^ ]*\)python$\/\1$(PYTHON3)/" debian/$(@)/usr/share/doc/$(@)/examples/*.py
738+ dh_compress -p $@
739+ dh_shlibdeps -p $@ -ldebian/$@/usr/lib
740+ dh_fixperms -p $@
741+ dh_installdeb -p $@
742+ # Call after all other files have been created and installed
743+ dh_python3 -p $@
744+ dh_gencontrol -p $@
745+ dh_md5sums -p $@
746+ dh_builddeb -p $@
747+
748+$(PYTHON3_DBG_PKG): build $(PYTHON3_PKG)
749+ dh_testdir
750+ dh_testroot
751+ for v in $(PY3VERS); do \
752+ pylib=$$(python$$v -c 'from distutils import sysconfig; print(sysconfig.get_python_lib(1))'); \
753+ echo $$pylib >> debian/$@.dirs; \
754+ echo python$$v/_snackmodule_d.so $$pylib/ \
755+ >> debian/$@.install; \
756+ done
757+ dh_installdirs -p $@
758+ dh_install -p $@ --sourcedir=$(BUILD_TREE)
759+ mkdir -p debian/$(@)/usr/share/doc
760+ ln -sf $(PYTHON3_PKG) debian/$(@)/usr/share/doc/$(@)
761 dh_compress -p $@
762 dh_shlibdeps -p $@ -ldebian/$@/usr/lib
763 dh_fixperms -p $@
764 dh_installdeb -p $@
765+ # Call after all other files have been created and installed
766+ dh_python3 -p $@
767 dh_gencontrol -p $@
768 dh_md5sums -p $@
769 dh_builddeb -p $@

Subscribers

People subscribed via source and target branches