Merge lp:~tony-badwolf/quickly/890318again into lp:quickly

Proposed by Tony Byrne
Status: Needs review
Proposed branch: lp:~tony-badwolf/quickly/890318again
Merge into: lp:quickly
Diff against target: 59 lines (+36/-1)
2 files modified
data/templates/ubuntu-application/project_root/python_lib/Builder.py (+2/-1)
data/templates/ubuntu-application/project_root/tests/test_builder.py (+34/-0)
To merge this branch: bzr merge lp:~tony-badwolf/quickly/890318again
Reviewer Review Type Date Requested Status
Quickly Developers Pending
Review via email: mp+84406@code.launchpad.net

Description of the change

Builder.py contains a function to change any widget name into a valid python name. This branch applies it to signal names also. Previous branch only checks for "-" in signal name (google "enumerate badness" to why this is inadequate) and does not check signals from "anonymous" top level windows.

To post a comment you must log in.

Unmerged revisions

641. By Tony Byrne <email address hidden> <email address hidden>

Convert both widget and signal name to a valid python variable name
fixes bug 890318

640. By Didier Roche-Tolomelli

Merge David's fix for fixing signal autoconnect does not work with
signal names which contain hypens (LP: #890318). Thanks!

639. By Michael Terry

fix tests to pass with latest platform and quickly changes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/templates/ubuntu-application/project_root/python_lib/Builder.py'
2--- data/templates/ubuntu-application/project_root/python_lib/Builder.py 2011-11-14 17:14:44 +0000
3+++ data/templates/ubuntu-application/project_root/python_lib/Builder.py 2011-12-04 19:20:30 +0000
4@@ -247,7 +247,6 @@
5 # Now, automatically find any the user didn't specify in glade
6 for sig in signal_names:
7 # using convention suggested by glade
8- sig = sig.replace("-", "_")
9 handler_names = ["on_%s_%s" % (widget_name, sig)]
10
11 # Using the convention that the top level window is not
12@@ -255,6 +254,8 @@
13 # on_destroy() instead of on_windowname_destroy()
14 if widget is callback_obj:
15 handler_names.append("on_%s" % sig)
16+
17+ handler_names = [make_pyname(x) for x in handler_names]
18
19 do_connect(item, sig, handler_names,
20 callback_handler_dict, builder.connections)
21
22=== added file 'data/templates/ubuntu-application/project_root/tests/test_builder.py'
23--- data/templates/ubuntu-application/project_root/tests/test_builder.py 1970-01-01 00:00:00 +0000
24+++ data/templates/ubuntu-application/project_root/tests/test_builder.py 2011-12-04 19:20:30 +0000
25@@ -0,0 +1,34 @@
26+#!/usr/bin/python
27+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
28+### BEGIN LICENSE
29+# This file is in the public domain
30+### END LICENSE
31+
32+import sys
33+import os.path
34+import nose
35+from nose.tools import eq_
36+
37+sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), "..")))
38+
39+try:
40+ from python_name_lib import Builder
41+except ImportError:
42+ from python_lib import Builder
43+
44+PYTHON_VARIABLE_NAME_DATA = [
45+['on_widget_file-set', 'on_widget_file_set'],
46+['mother-in-law', 'mother_in_law'],
47+["don't expect this to work?", "don_t_expect_this_to_work_"],
48+]
49+
50+def test_make_pyname():
51+ for raw_string, expected in PYTHON_VARIABLE_NAME_DATA:
52+ yield assert_make_pyname, raw_string, expected
53+
54+def assert_make_pyname(raw_string, expected):
55+ actual = Builder.make_pyname(raw_string)
56+ eq_(expected, actual)
57+
58+if __name__ == '__main__':
59+ nose.runmodule()

Subscribers

People subscribed via source and target branches