Merge lp:~quickly-committers/quickly/refactor-project-root3 into lp:quickly

Proposed by Tony Byrne
Status: Merged
Merged at revision: 608
Proposed branch: lp:~quickly-committers/quickly/refactor-project-root3
Merge into: lp:quickly
Diff against target: 1819 lines (+634/-518)
30 files modified
data/templates/ubuntu-application/create.py (+2/-2)
data/templates/ubuntu-application/edit.py (+4/-2)
data/templates/ubuntu-application/help/tutorial.xml (+1/-1)
data/templates/ubuntu-application/internal/apportutils.py (+2/-2)
data/templates/ubuntu-application/license.py (+4/-2)
data/templates/ubuntu-application/project_root/bin/project_name (+2/-34)
data/templates/ubuntu-application/project_root/python/Aboutcamel_case_nameDialog.py (+24/-0)
data/templates/ubuntu-application/project_root/python/Preferencescamel_case_nameDialog.py (+51/-0)
data/templates/ubuntu-application/project_root/python/__init__.py (+48/-0)
data/templates/ubuntu-application/project_root/python/camel_case_nameWindow.py (+30/-0)
data/templates/ubuntu-application/project_root/python_lib/AboutDialog.py (+7/-18)
data/templates/ubuntu-application/project_root/python_lib/Builder.py (+8/-6)
data/templates/ubuntu-application/project_root/python_lib/PreferencesDialog.py (+31/-35)
data/templates/ubuntu-application/project_root/python_lib/Window.py (+23/-24)
data/templates/ubuntu-application/project_root/python_lib/__init__.py (+13/-0)
data/templates/ubuntu-application/project_root/python_lib/helpers.py (+30/-16)
data/templates/ubuntu-application/project_root/python_lib/preferences.py (+1/-6)
data/templates/ubuntu-application/project_root/python_lib/python_nameconfig.py (+4/-0)
data/templates/ubuntu-application/project_root/setup.py (+2/-2)
data/templates/ubuntu-application/store/python/dialog_camel_case_nameDialog.py (+1/-4)
data/templates/ubuntu-application/store/python/indicator.py (+3/-4)
data/templates/ubuntu-application/test/apport/apport.sh (+27/-27)
data/templates/ubuntu-application/test/builder/builder.py (+4/-4)
data/templates/ubuntu-application/test/filelist.sh (+10/-5)
data/templates/ubuntu-application/test/preferences.py (+5/-3)
data/templates/ubuntu-cli/project_root/bin/project_name (+2/-44)
data/templates/ubuntu-cli/project_root/python/__init__.py (+48/-0)
data/templates/ubuntu-pygame/project_root/bin/project_name (+2/-237)
data/templates/ubuntu-pygame/project_root/python/__init__.py (+237/-0)
quickly/launchpadaccess.py (+8/-40)
To merge this branch: bzr merge lp:~quickly-committers/quickly/refactor-project-root3
Reviewer Review Type Date Requested Status
Quickly Developers Pending
Review via email: mp+53539@code.launchpad.net

Description of the change

Put launchpad integration and application indicator back into python_lib instead of user code.
Fixed application indicator bug.

Note: needs unit tests, some are impossible for me as they are now natty specific.

To post a comment you must log in.
604. By Michael Terry

merge from trunk

605. By Michael Terry

use implicit relative imports for intra-python_lib imports to avoid issues with the test suite

606. By Michael Terry

merge in launchpadlib changes for ease of validating test suite

607. By Michael Terry

whoops, undo accidental __quickly_data_directory__ reset

608. By Michael Terry

make relative imports super-explicit so that python-distutils-extra can know to skip them when scanning

609. By Michael Terry

change apport test to point at new Window.py

610. By Michael Terry

more robust .pyc cleaning after running preferences unit test

Revision history for this message
Michael Terry (mterry) wrote :

OK, test suite passes in natty now, assuming one has the fix for bug 746565.

I think this is looking in good shape! I'm going to do some more testing, but seems good so far. I'd like to land this for the post-11.04-beta quickly release.

611. By Michael Terry

merge from trunk again

612. By Michael Terry

some fixes noticed when updating tutorial

613. By Michael Terry

merge from trunk (tutorial refresh)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/templates/ubuntu-application/create.py'
2--- data/templates/ubuntu-application/create.py 2011-01-04 19:05:46 +0000
3+++ data/templates/ubuntu-application/create.py 2011-04-01 21:06:39 +0000
4@@ -86,8 +86,8 @@
5 relative_dir = relative_dir.replace('python', python_name)
6
7 for directory in dirs:
8- if directory == 'python':
9- directory = python_name
10+ if directory.startswith('python'):
11+ directory = directory.replace('python', python_name)
12 os.mkdir(os.path.join(relative_dir, directory))
13 for filename in files:
14 quicklyutils.file_from_template(root, filename, relative_dir, substitutions)
15
16=== modified file 'data/templates/ubuntu-application/edit.py'
17--- data/templates/ubuntu-application/edit.py 2010-11-22 19:01:48 +0000
18+++ data/templates/ubuntu-application/edit.py 2011-04-01 21:06:39 +0000
19@@ -47,7 +47,9 @@
20 filelist = []
21 for root, dirs, files in os.walk('./'):
22 for name in files:
23- if name.endswith('.py') and name not in ('__init__.py', 'setup.py'):
24+ hide_path = root.endswith('_lib')
25+ py = name.endswith('.py')
26+ if py and not hide_path and name not in ('setup.py'):
27 filelist.append(os.path.join(root, name))
28
29 # if config not already loaded
30@@ -55,7 +57,7 @@
31 configurationhandler.loadConfig()
32
33 # add launcher which does not end with .py
34-filelist.append('bin/' + configurationhandler.project_config['project'])
35+# filelist.append('bin/' + configurationhandler.project_config['project'])
36
37 # add helpfile sources
38 filelist.extend(glob.glob('help/C/*.page'))
39
40=== modified file 'data/templates/ubuntu-application/help/tutorial.xml'
41--- data/templates/ubuntu-application/help/tutorial.xml 2011-04-01 21:02:04 +0000
42+++ data/templates/ubuntu-application/help/tutorial.xml 2011-04-01 21:06:39 +0000
43@@ -3,7 +3,7 @@
44 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
45
46 <!ENTITY appname "<application>Quickly</application>" >
47- <!ENTITY appversion "0.6.1" >
48+ <!ENTITY appversion "11.03.1" >
49 ] >
50
51 <book lang="en" id="index">
52
53=== modified file 'data/templates/ubuntu-application/internal/apportutils.py'
54--- data/templates/ubuntu-application/internal/apportutils.py 2010-12-20 20:33:12 +0000
55+++ data/templates/ubuntu-application/internal/apportutils.py 2011-04-01 21:06:39 +0000
56@@ -90,8 +90,8 @@
57
58 def insert_lpi_if_required(project_name):
59 camel_case_project_name = quickly.templatetools.get_camel_case_name(project_name)
60- existing_base_filename = os.path.join(quickly.templatetools.python_name(project_name),
61- "Base%sWindow.py"%camel_case_project_name)
62+ existing_base_filename = os.path.join(quickly.templatetools.python_name(project_name) + '_lib',
63+ "Window.py")
64 existing_ui_filename = os.path.join("data", "ui", "%sWindow.ui"%camel_case_project_name)
65
66 if os.path.isfile(existing_base_filename) and os.path.isfile(existing_ui_filename):
67
68=== modified file 'data/templates/ubuntu-application/license.py'
69--- data/templates/ubuntu-application/license.py 2010-10-18 18:39:04 +0000
70+++ data/templates/ubuntu-application/license.py 2011-04-01 21:06:39 +0000
71@@ -234,7 +234,9 @@
72
73 # update license in config.py, setup.py and refresh COPYING if needed
74 try:
75- config_file = '%s/%sconfig.py' % (python_name, python_name)
76+ config_file = '%s_lib/%sconfig.py' % (python_name, python_name)
77+ if not os.path.exists(config_file):
78+ config_file = '%s/%sconfig.py' % (python_name, python_name) # old location
79 for line in file(config_file, 'r'):
80 fields = line.split(' = ') # Separate variable from value
81 if fields[0] == '__license__' and fields[1].strip() != "'%s'" % license:
82@@ -260,7 +262,7 @@
83 msg = _("Can't update license in setup.py file\n")
84 raise LicenceError(msg)
85 except (OSError, IOError), e:
86- msg = _("%s/%sconfig.py file not found.") % (python_name, python_name)
87+ msg = _("%s file not found.") % (config_file)
88 raise LicenceError(msg)
89
90 # update About dialog, if present:
91
92=== modified file 'data/templates/ubuntu-application/project_root/bin/project_name'
93--- data/templates/ubuntu-application/project_root/bin/project_name 2010-12-07 14:14:08 +0000
94+++ data/templates/ubuntu-application/project_root/bin/project_name 2011-04-01 21:06:39 +0000
95@@ -6,8 +6,6 @@
96
97 import sys
98 import os
99-import gtk
100-import logging
101
102 import gettext
103 from gettext import gettext as _
104@@ -31,35 +29,5 @@
105 if python_path:
106 os.putenv('PYTHONPATH', "%s:%s" % (os.getenv('PYTHONPATH', ''), ':'.join(python_path))) # for subprocesses
107
108-
109-from python_name import (Basecamel_case_nameWindow)
110-import python_name.helpers as helpers
111-from python_name.preferences import preferences
112-
113-# See Basecamel_case_nameWindow.py for more details about how this class works
114-class camel_case_nameWindow(Basecamel_case_nameWindow.Basecamel_case_nameWindow):
115- __gtype_name__ = "camel_case_nameWindow"
116-
117- def finish_initializing(self, builder):
118- """Set up the main window"""
119- super(camel_case_nameWindow, self).finish_initializing(builder)
120-
121- # Code for other initialization actions should be added here.
122- preferences.connect('changed', self.on_preferences_changed)
123-
124- def on_preferences_changed(self, widget, data=None):
125- logging.debug('main window received preferences changed')
126- for key in data:
127- logging.debug('preference changed: %s = %s' % (key, preferences[key]))
128-
129-if __name__ == "__main__":
130- # Support for command line options. See helpers.py to add more.
131- helpers.parse_options()
132-
133- # Run the application.
134- preferences.db_connect()
135- preferences.load()
136- window = camel_case_nameWindow()
137- window.show()
138- gtk.main()
139- preferences.save()
140+import python_name
141+python_name.main()
142
143=== added file 'data/templates/ubuntu-application/project_root/python/Aboutcamel_case_nameDialog.py'
144--- data/templates/ubuntu-application/project_root/python/Aboutcamel_case_nameDialog.py 1970-01-01 00:00:00 +0000
145+++ data/templates/ubuntu-application/project_root/python/Aboutcamel_case_nameDialog.py 2011-04-01 21:06:39 +0000
146@@ -0,0 +1,24 @@
147+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
148+### BEGIN LICENSE
149+# This file is in the public domain
150+### END LICENSE
151+
152+import gettext
153+from gettext import gettext as _
154+gettext.textdomain('project_name')
155+
156+import logging
157+logger = logging.getLogger('python_name')
158+
159+from python_name_lib.AboutDialog import AboutDialog
160+
161+# See python_name_lib.AboutDialog.py for more details about how this class works.
162+class Aboutcamel_case_nameDialog(AboutDialog):
163+ __gtype_name__ = "Aboutcamel_case_nameDialog"
164+
165+ def finish_initializing(self, builder):
166+ """Set up the about dialog"""
167+ super(Aboutcamel_case_nameDialog, self).finish_initializing(builder)
168+
169+ # Code for other initialization actions should be added here.
170+
171
172=== added file 'data/templates/ubuntu-application/project_root/python/Preferencescamel_case_nameDialog.py'
173--- data/templates/ubuntu-application/project_root/python/Preferencescamel_case_nameDialog.py 1970-01-01 00:00:00 +0000
174+++ data/templates/ubuntu-application/project_root/python/Preferencescamel_case_nameDialog.py 2011-04-01 21:06:39 +0000
175@@ -0,0 +1,51 @@
176+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
177+### BEGIN LICENSE
178+# This file is in the public domain
179+### END LICENSE
180+
181+# This is your preferences dialog.
182+#
183+# Define your preferences dictionary in the __init__.main() function.
184+# The widget names in the PreferencesTestProjectDialog.ui
185+# file need to correspond to the keys in the preferences dictionary.
186+#
187+# Each preference also need to be defined in the 'widget_methods' map below
188+# to show up in the dialog itself. Provide three bits of information:
189+# 1) The first entry is the method on the widget that grabs a value from the
190+# widget.
191+# 2) The second entry is the method on the widget that sets the widgets value
192+# from a stored preference.
193+# 3) The third entry is a signal the widget will send when the contents have
194+# been changed by the user. The preferences dictionary is always up to
195+# date and will signal the rest of the application about these changes.
196+# The values will be saved to desktopcouch when the application closes.
197+#
198+# TODO: replace widget_methods with your own values
199+
200+
201+widget_methods = {
202+ 'example_entry': ['get_text', 'set_text', 'changed'],
203+}
204+
205+import gettext
206+from gettext import gettext as _
207+gettext.textdomain('project_name')
208+
209+import logging
210+logger = logging.getLogger('python_name')
211+
212+from python_name_lib.PreferencesDialog import PreferencesDialog
213+
214+class Preferencescamel_case_nameDialog(PreferencesDialog):
215+ __gtype_name__ = "Preferencescamel_case_nameDialog"
216+
217+ def finish_initializing(self, builder):
218+ """Set up the preferences dialog"""
219+ super(Preferencescamel_case_nameDialog, self).finish_initializing(builder)
220+
221+ # populate the dialog from the preferences dictionary
222+ # using the methods from widget_methods
223+ self.widget_methods = widget_methods
224+ self.set_widgets_from_preferences()
225+
226+ # Code for other initialization actions should be added here.
227
228=== modified file 'data/templates/ubuntu-application/project_root/python/__init__.py'
229--- data/templates/ubuntu-application/project_root/python/__init__.py 2009-07-06 15:26:28 +0000
230+++ data/templates/ubuntu-application/project_root/python/__init__.py 2011-04-01 21:06:39 +0000
231@@ -0,0 +1,48 @@
232+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
233+### BEGIN LICENSE
234+# This file is in the public domain
235+### END LICENSE
236+
237+import optparse
238+
239+import gettext
240+from gettext import gettext as _
241+gettext.textdomain('project_name')
242+
243+import gtk
244+
245+from python_name import camel_case_nameWindow
246+
247+from python_name_lib import set_up_logging, preferences, get_version
248+
249+def parse_options():
250+ """Support for command line options"""
251+ parser = optparse.OptionParser(version="%%prog %s" % get_version())
252+ parser.add_option(
253+ "-v", "--verbose", action="count", dest="verbose",
254+ help=_("Show debug messages (-vv debugs python_name_lib also)"))
255+ (options, args) = parser.parse_args()
256+
257+ set_up_logging(options)
258+
259+def main():
260+ 'constructor for your class instances'
261+ parse_options()
262+
263+ # preferences
264+ # set some values for our first session
265+ # TODO: replace defaults with your own values
266+ default_preferences = {
267+ 'example_entry': 'I remember stuff',
268+ }
269+ preferences.update(default_preferences)
270+ # user's stored preferences are used for 2nd and subsequent sessions
271+ preferences.db_connect()
272+ preferences.load()
273+
274+ # Run the application.
275+ window = camel_case_nameWindow.camel_case_nameWindow()
276+ window.show()
277+ gtk.main()
278+
279+ preferences.save()
280
281=== added file 'data/templates/ubuntu-application/project_root/python/camel_case_nameWindow.py'
282--- data/templates/ubuntu-application/project_root/python/camel_case_nameWindow.py 1970-01-01 00:00:00 +0000
283+++ data/templates/ubuntu-application/project_root/python/camel_case_nameWindow.py 2011-04-01 21:06:39 +0000
284@@ -0,0 +1,30 @@
285+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
286+### BEGIN LICENSE
287+# This file is in the public domain
288+### END LICENSE
289+
290+import gettext
291+from gettext import gettext as _
292+gettext.textdomain('project_name')
293+
294+import gtk
295+import logging
296+logger = logging.getLogger('python_name')
297+
298+from python_name_lib import Window
299+from python_name.Aboutcamel_case_nameDialog import Aboutcamel_case_nameDialog
300+from python_name.Preferencescamel_case_nameDialog import Preferencescamel_case_nameDialog
301+
302+# See python_name_lib.Window.py for more details about how this class works
303+class camel_case_nameWindow(Window):
304+ __gtype_name__ = "camel_case_nameWindow"
305+
306+ def finish_initializing(self, builder):
307+ """Set up the main window"""
308+ super(camel_case_nameWindow, self).finish_initializing(builder)
309+
310+ self.AboutDialog = Aboutcamel_case_nameDialog
311+ self.PreferencesDialog = Preferencescamel_case_nameDialog
312+
313+ # Code for other initialization actions should be added here.
314+
315
316=== added directory 'data/templates/ubuntu-application/project_root/python_lib'
317=== renamed file 'data/templates/ubuntu-application/project_root/python/Aboutcamel_case_nameDialog.py' => 'data/templates/ubuntu-application/project_root/python_lib/AboutDialog.py'
318--- data/templates/ubuntu-application/project_root/python/Aboutcamel_case_nameDialog.py 2010-12-06 14:55:14 +0000
319+++ data/templates/ubuntu-application/project_root/python_lib/AboutDialog.py 2011-04-01 21:06:39 +0000
320@@ -5,20 +5,16 @@
321
322 import gtk
323
324-from python_name.helpers import get_builder
325-
326-import gettext
327-from gettext import gettext as _
328-gettext.textdomain('project_name')
329-
330-class Aboutcamel_case_nameDialog(gtk.AboutDialog):
331- __gtype_name__ = "Aboutcamel_case_nameDialog"
332+from . helpers import get_builder
333+
334+class AboutDialog(gtk.AboutDialog):
335+ __gtype_name__ = "AboutDialog"
336
337 def __new__(cls):
338 """Special static method that's automatically called by Python when
339 constructing a new instance of this class.
340
341- Returns a fully instantiated Aboutcamel_case_nameDialog object.
342+ Returns a fully instantiated AboutDialog object.
343 """
344 builder = get_builder('Aboutcamel_case_nameDialog')
345 new_object = builder.get_object("about_python_name_dialog")
346@@ -29,8 +25,8 @@
347 """Called while initializing this instance in __new__
348
349 finish_initalizing should be called after parsing the ui definition
350- and creating a Aboutcamel_case_nameDialog object with it in order to
351- finish initializing the start of the new Aboutcamel_case_nameDialog
352+ and creating a AboutDialog object with it in order
353+ to finish initializing the start of the new Aboutcamel_case_nameDialog
354 instance.
355
356 Put your initialization code in here and leave __init__ undefined.
357@@ -39,10 +35,3 @@
358 self.builder = builder
359 self.ui = builder.get_ui(self)
360
361- # Code for other initialization actions should be added here.
362-
363-
364-if __name__ == "__main__":
365- dialog = Aboutcamel_case_nameDialog()
366- dialog.show()
367- gtk.main()
368
369=== renamed file 'data/templates/ubuntu-application/project_root/python/Builder.py' => 'data/templates/ubuntu-application/project_root/python_lib/Builder.py'
370--- data/templates/ubuntu-application/project_root/python/Builder.py 2010-12-18 20:05:13 +0000
371+++ data/templates/ubuntu-application/project_root/python_lib/Builder.py 2011-04-01 21:06:39 +0000
372@@ -11,6 +11,8 @@
373 import inspect
374 import functools
375 import logging
376+logger = logging.getLogger('python_name_lib')
377+
378 from xml.etree.cElementTree import ElementTree
379
380 # this module is big so uses some conventional prefixes and postfixes
381@@ -49,7 +51,7 @@
382 now he can define any likely candidates in glade and notice which
383 ones get triggered when he plays with the project.
384 this method does not appear in gtk.Builder'''
385- logging.debug('''tried to call non-existent function:%s()
386+ logger.debug('''tried to call non-existent function:%s()
387 expected in %s
388 args:%s
389 kwargs:%s''', handler_name, filename, args, kwargs)
390@@ -115,7 +117,7 @@
391 connection_dict[item[0]] = handler
392
393 # replace the run time warning
394- logging.warn("expected handler '%s' in %s",
395+ logger.warn("expected handler '%s' in %s",
396 item[0], filename)
397
398 # connect glade define handlers
399@@ -124,7 +126,7 @@
400 # let's tell the user how we applied the glade design
401 for connection in self.connections:
402 widget_name, signal_name, handler_name = connection
403- logging.debug("connect builder by design '%s', '%s', '%s'",
404+ logger.debug("connect builder by design '%s', '%s', '%s'",
405 widget_name, signal_name, handler_name)
406
407 def get_ui(self, callback_obj=None, by_name=True):
408@@ -162,7 +164,7 @@
409 pyname = make_pyname(name)
410 if pyname != name:
411 if hasattr(self, pyname):
412- logging.debug(
413+ logger.debug(
414 "Builder: Not binding %s, name already exists", pyname)
415 else:
416 setattr(self, pyname, obj)
417@@ -264,7 +266,7 @@
418 widget.connect(signal_name, callback_handler_dict[handler_name])
419 connections.append(connection)
420
421- logging.debug("connect builder by name '%s','%s', '%s'",
422+ logger.debug("connect builder by name '%s','%s', '%s'",
423 widget_name, signal_name, handler_name)
424
425
426@@ -283,4 +285,4 @@
427 pass
428
429 for handler_name in unconnected:
430- logging.debug("Not connected to builder '%s'", handler_name)
431+ logger.debug("Not connected to builder '%s'", handler_name)
432
433=== renamed file 'data/templates/ubuntu-application/project_root/python/Preferencescamel_case_nameDialog.py' => 'data/templates/ubuntu-application/project_root/python_lib/PreferencesDialog.py'
434--- data/templates/ubuntu-application/project_root/python/Preferencescamel_case_nameDialog.py 2010-12-08 21:56:03 +0000
435+++ data/templates/ubuntu-application/project_root/python_lib/PreferencesDialog.py 2011-04-01 21:06:39 +0000
436@@ -12,30 +12,21 @@
437 each widget calls set_preference(...) when it has adjusted value
438 """
439
440-# defined because there are choices for some widget types
441-# TODO: replace example widget_methods with your values
442-widget_methods = {
443-'example_entry': ['get_text', 'set_text', 'changed'],
444-}
445-
446 import gtk
447 import logging
448-
449-from python_name.helpers import get_builder, show_uri, get_help_uri
450-from python_name.preferences import preferences
451-
452-import gettext
453-from gettext import gettext as _
454-gettext.textdomain('project_name')
455-
456-class Preferencescamel_case_nameDialog(gtk.Dialog):
457- __gtype_name__ = "Preferencescamel_case_nameDialog"
458+logger = logging.getLogger('python_name_lib')
459+
460+from . helpers import get_builder, show_uri, get_help_uri
461+from . preferences import preferences
462+
463+class PreferencesDialog(gtk.Dialog):
464+ __gtype_name__ = "PreferencesDialog"
465
466 def __new__(cls):
467 """Special static method that's automatically called by Python when
468 constructing a new instance of this class.
469
470- Returns a fully instantiated Preferencescamel_case_nameDialog object.
471+ Returns a fully instantiated PreferencesDialog object.
472 """
473 builder = get_builder('Preferencescamel_case_nameDialog')
474 new_object = builder.get_object("preferences_python_name_dialog")
475@@ -46,7 +37,7 @@
476 """Called while initializing this instance in __new__
477
478 finish_initalizing should be called after parsing the ui definition
479- and creating a Preferencescamel_case_nameDialog object with it in order to
480+ and creating a PreferencesDialog object with it in order to
481 finish initializing the start of the new Perferencescamel_case_nameDialog
482 instance.
483
484@@ -57,8 +48,8 @@
485 self.builder = builder
486 self.ui = builder.get_ui(self, True)
487
488- # TODO: code for other initialization actions should be added here
489- self.set_widgets_from_preferences()
490+ # code for other initialization actions should be added here
491+ self.widget_methods = []
492
493 def set_widgets_from_preferences(self):
494 ''' these widgets show values in the preferences dictionary '''
495@@ -73,23 +64,30 @@
496 if widget is None:
497 # this preference is not adjustable by this dialog
498 # for example: window and dialog geometries
499- logging.debug('no widget for preference: %s' % key)
500+ logger.debug('no widget for preference: %s' % key)
501 return
502
503- logging.debug('set_widget_from_preference: %s' % key)
504+ logger.debug('set_widget_from_preference: %s' % key)
505 try:
506- write_method_name=widget_methods[key][1]
507+ write_method_name = self.widget_methods[key][1]
508 except KeyError:
509- logging.warn('%s not in widget_methods' % key)
510+ logger.warn('%s not in widget_methods' % key)
511 return
512
513 try:
514 method = getattr(widget, write_method_name)
515 except AttributeError:
516- logging.warn("'%s' does not have a '%s' method.\n Please edit 'widget_methods' in %s" % (key, write_method_name, __file__))
517+ logger.warn("""'%s' does not have a '%s' method.
518+Please edit 'widget_methods' in %s"""
519+ % (key, write_method_name, self.__gtype_name__))
520 return
521
522- widget.connect(widget_methods[key][2], self.set_preference)
523+ try:
524+ widget.connect(self.widget_methods[key][2], self.set_preference)
525+ except TypeError:
526+ logger.warn("""'%s' unknown signal name '%s'
527+Please edit 'widget_methods' in %s"""
528+ % (key, self.widget_methods[key][2], self.__gtype_name__))
529
530 method(value)
531
532@@ -105,23 +103,25 @@
533 '''set a preference from a widget'''
534 key = self.get_key_for_widget(widget)
535 if key is None:
536- logging.warn('''This widget will not write to a preference.
537+ logger.warn('''This widget will not write to a preference.
538 The preference must already exist so add this widget's name
539-to defaults in preferences module''')
540+to default_preferences in your main function''')
541 return
542
543 # set_widget_from_preference is called first
544 # so no KeyError test is needed here
545- read_method_name=widget_methods[key][0]
546+ read_method_name = self.widget_methods[key][0]
547
548 try:
549 read_method = getattr(widget, read_method_name)
550 except AttributeError:
551- logging.warn("'%s' does not have a '%s' method.\n Please edit 'widget_methods' in %s" % (key, read_method_name, __file__))
552+ logger.warn("""'%s' does not have a '%s' method.
553+Please edit 'widget_methods' in %s"""
554+ % (key, read_method_name, self.__gtype_name__))
555 return
556
557 value=read_method()
558- logging.debug('set_preference: %s = %s' % (key, str(value)))
559+ logger.debug('set_preference: %s = %s' % (key, str(value)))
560 preferences[key] = value
561
562 def on_btn_close_clicked(self, widget, data=None):
563@@ -130,7 +130,3 @@
564 def on_btn_help_clicked(self, widget, data=None):
565 show_uri(self, "ghelp:%s" % get_help_uri('preferences'))
566
567-if __name__ == "__main__":
568- dialog = Preferencescamel_case_nameDialog()
569- dialog.show()
570- gtk.main()
571
572=== renamed file 'data/templates/ubuntu-application/project_root/python/Basecamel_case_nameWindow.py' => 'data/templates/ubuntu-application/project_root/python_lib/Window.py'
573--- data/templates/ubuntu-application/project_root/python/Basecamel_case_nameWindow.py 2011-04-01 21:02:04 +0000
574+++ data/templates/ubuntu-application/project_root/python_lib/Window.py 2011-04-01 21:06:39 +0000
575@@ -5,21 +5,15 @@
576
577 import gtk
578 import logging
579-
580-from python_name import (
581- Aboutcamel_case_nameDialog, Preferencescamel_case_nameDialog)
582-import python_name.helpers as helpers
583-from python_name.preferences import preferences
584-
585-import gettext
586-from gettext import gettext as _
587-gettext.textdomain('project_name')
588-
589+logger = logging.getLogger('python_name_lib')
590+
591+from . helpers import get_builder, show_uri, get_help_uri
592+from . preferences import preferences
593
594 # This class is meant to be subclassed by camel_case_nameWindow. It provides
595 # common functions and some boilerplate.
596-class Basecamel_case_nameWindow(gtk.Window):
597- __gtype_name__ = "Basecamel_case_nameWindow"
598+class Window(gtk.Window):
599+ __gtype_name__ = "Window"
600
601 # To construct a new instance of this method, the following notable
602 # methods are called in this order:
603@@ -37,7 +31,7 @@
604
605 Returns a fully instantiated Basecamel_case_nameWindow object.
606 """
607- builder = helpers.get_builder('camel_case_nameWindow')
608+ builder = get_builder('camel_case_nameWindow')
609 new_object = builder.get_object("python_name_window")
610 new_object.finish_initializing(builder)
611 return new_object
612@@ -52,7 +46,11 @@
613 # Get a reference to the builder and set up the signals.
614 self.builder = builder
615 self.ui = builder.get_ui(self, True)
616- self.preferences_dialog = None
617+ self.PreferencesDialog = None # class
618+ self.preferences_dialog = None # instance
619+ self.AboutDialog = None # class
620+
621+ preferences.connect('changed', self.on_preferences_changed)
622
623 # Optional Launchpad integration
624 # This shouldn't crash if not found as it is simply used for bug reporting.
625@@ -79,11 +77,11 @@
626 pass
627
628 def on_mnu_contents_activate(self, widget, data=None):
629- helpers.show_uri(self, "ghelp:%s" % helpers.get_help_uri())
630+ show_uri(self, "ghelp:%s" % get_help_uri())
631
632 def on_mnu_about_activate(self, widget, data=None):
633 """Display the about box for project_name."""
634- about = Aboutcamel_case_nameDialog.Aboutcamel_case_nameDialog()
635+ about = self.AboutDialog()
636 response = about.run()
637 about.destroy()
638
639@@ -96,11 +94,11 @@
640 use the present() method to move the already-open dialog
641 where the user can see it."""
642 if self.preferences_dialog is not None:
643- logging.debug('show existing preferences_dialog')
644+ logger.debug('show existing preferences_dialog')
645 self.preferences_dialog.present()
646 else:
647- logging.debug('create new preferences_dialog')
648- self.preferences_dialog = Preferencescamel_case_nameDialog.Preferencescamel_case_nameDialog()
649+ logger.debug('create new preferences_dialog')
650+ self.preferences_dialog = self.PreferencesDialog()
651 self.preferences_dialog.connect('destroy', self.on_preferences_dialog_destroyed)
652 self.preferences_dialog.show()
653 # destroy command moved into dialog to allow for a help button
654@@ -114,16 +112,17 @@
655 # Clean up code for saving application state should be added here.
656 gtk.main_quit()
657
658+ def on_preferences_changed(self, widget, data=None):
659+ logger.debug('main window received preferences changed')
660+ for key in data:
661+ logger.debug('preference changed: %s = %s' % (key, preferences[key]))
662+
663 def on_preferences_dialog_destroyed(self, widget, data=None):
664 '''only affects gui
665
666 logically there is no difference between the user closing,
667 minimising or ignoring the preferences dialog'''
668- logging.debug('on_preferences_dialog_destroyed')
669+ logger.debug('on_preferences_dialog_destroyed')
670 # to determine whether to create or present preferences_dialog
671 self.preferences_dialog = None
672
673-if __name__ == "__main__":
674- window = Basecamel_case_nameWindow()
675- window.show()
676- gtk.main()
677
678=== added file 'data/templates/ubuntu-application/project_root/python_lib/__init__.py'
679--- data/templates/ubuntu-application/project_root/python_lib/__init__.py 1970-01-01 00:00:00 +0000
680+++ data/templates/ubuntu-application/project_root/python_lib/__init__.py 2011-04-01 21:06:39 +0000
681@@ -0,0 +1,13 @@
682+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
683+### BEGIN LICENSE
684+# This file is in the public domain
685+### END LICENSE
686+
687+'''facade - makes python_name_lib package easy to refactor
688+
689+while keeping its api constant'''
690+from . helpers import set_up_logging
691+from . preferences import preferences
692+from . Window import Window
693+from . python_nameconfig import get_version
694+
695
696=== renamed file 'data/templates/ubuntu-application/project_root/python/helpers.py' => 'data/templates/ubuntu-application/project_root/python_lib/helpers.py'
697--- data/templates/ubuntu-application/project_root/python/helpers.py 2011-03-30 17:57:06 +0000
698+++ data/templates/ubuntu-application/project_root/python_lib/helpers.py 2011-04-01 21:06:39 +0000
699@@ -4,12 +4,13 @@
700 ### END LICENSE
701
702 """Helpers for an Ubuntu application."""
703-
704+import logging
705 import os
706+
707 import gtk
708
709-from python_name.python_nameconfig import get_data_file, __version__
710-from python_name.Builder import Builder
711+from . python_nameconfig import get_data_file
712+from . Builder import Builder
713
714 import gettext
715 from gettext import gettext as _
716@@ -41,21 +42,34 @@
717
718 return "file:///"+media_filename
719
720-
721-def parse_options():
722- """Support for command line options"""
723- import logging
724- import optparse
725- parser = optparse.OptionParser(version="%%prog %s" % __version__)
726- parser.add_option(
727- "-v", "--verbose", action="store_true", dest="verbose",
728- help=_("Show debug messages"))
729- (options, args) = parser.parse_args()
730+class NullHandler(logging.Handler):
731+ def emit(self, record):
732+ pass
733+
734+def set_up_logging(opts):
735+ # add a handler to prevent basicConfig
736+ root = logging.getLogger()
737+ null_handler = NullHandler()
738+ root.addHandler(null_handler)
739+
740+ formatter = logging.Formatter("%(levelname)s:%(name)s: %(funcName)s() '%(message)s'")
741+
742+ logger = logging.getLogger('python_name')
743+ logger_sh = logging.StreamHandler()
744+ logger_sh.setFormatter(formatter)
745+ logger.addHandler(logger_sh)
746+
747+ lib_logger = logging.getLogger('python_name_lib')
748+ lib_logger_sh = logging.StreamHandler()
749+ lib_logger_sh.setFormatter(formatter)
750+ lib_logger.addHandler(lib_logger_sh)
751
752 # Set the logging level to show debug messages.
753- if options.verbose:
754- logging.basicConfig(level=logging.DEBUG)
755- logging.debug('logging enabled')
756+ if opts.verbose:
757+ logger.setLevel(logging.DEBUG)
758+ logger.debug('logging enabled')
759+ if opts.verbose > 1:
760+ lib_logger.setLevel(logging.DEBUG)
761
762 def get_help_uri(page=None):
763 # help_uri from source tree - default language
764
765=== renamed file 'data/templates/ubuntu-application/project_root/python/preferences.py' => 'data/templates/ubuntu-application/project_root/python_lib/preferences.py'
766--- data/templates/ubuntu-application/project_root/python/preferences.py 2011-02-22 20:43:24 +0000
767+++ data/templates/ubuntu-application/project_root/python_lib/preferences.py 2011-04-01 21:06:39 +0000
768@@ -5,11 +5,6 @@
769
770 """Provides a shared preferences dictionary"""
771
772-# TODO: replace defaults with your own values
773-defaults = {
774-'example_entry': 'I remember stuff',
775- }
776-
777 from desktopcouch.records.server import CouchDatabase
778 from desktopcouch.records.record import Record
779 import gtk
780@@ -102,4 +97,4 @@
781 self.emit('changed', (key,))
782
783 preferences = User_dict()
784-preferences.update(defaults)
785+
786
787=== renamed file 'data/templates/ubuntu-application/project_root/python/python_nameconfig.py' => 'data/templates/ubuntu-application/project_root/python_lib/python_nameconfig.py'
788--- data/templates/ubuntu-application/project_root/python/python_nameconfig.py 2011-03-30 17:57:06 +0000
789+++ data/templates/ubuntu-application/project_root/python_lib/python_nameconfig.py 2011-04-01 21:06:39 +0000
790@@ -57,3 +57,7 @@
791 raise project_path_not_found
792
793 return abs_data_path
794+
795+
796+def get_version():
797+ return __version__
798
799=== modified file 'data/templates/ubuntu-application/project_root/setup.py'
800--- data/templates/ubuntu-application/project_root/setup.py 2011-03-30 17:57:06 +0000
801+++ data/templates/ubuntu-application/project_root/setup.py 2011-04-01 21:06:39 +0000
802@@ -20,7 +20,7 @@
803
804 oldvalues = {}
805 try:
806- fin = file('python_name/python_nameconfig.py', 'r')
807+ fin = file('python_name_lib/python_nameconfig.py', 'r')
808 fout = file(fin.name + '.new', 'w')
809
810 for line in fin:
811@@ -35,7 +35,7 @@
812 fin.close()
813 os.rename(fout.name, fin.name)
814 except (OSError, IOError), e:
815- print ("ERROR: Can't find python_name/python_nameconfig.py")
816+ print ("ERROR: Can't find python_name_lib/python_nameconfig.py")
817 sys.exit(1)
818 return oldvalues
819
820
821=== modified file 'data/templates/ubuntu-application/store/python/dialog_camel_case_nameDialog.py'
822--- data/templates/ubuntu-application/store/python/dialog_camel_case_nameDialog.py 2010-12-18 20:05:13 +0000
823+++ data/templates/ubuntu-application/store/python/dialog_camel_case_nameDialog.py 2011-04-01 21:06:39 +0000
824@@ -5,10 +5,7 @@
825
826 import gtk
827
828-#TODO remove
829-#from python_name import Builder
830-
831-from python_name.helpers import get_builder
832+from python_name_lib.helpers import get_builder
833
834 import gettext
835 from gettext import gettext as _
836
837=== modified file 'data/templates/ubuntu-application/store/python/indicator.py'
838--- data/templates/ubuntu-application/store/python/indicator.py 2011-04-01 21:02:04 +0000
839+++ data/templates/ubuntu-application/store/python/indicator.py 2011-04-01 21:06:39 +0000
840@@ -8,7 +8,7 @@
841
842 import gtk
843
844-from python_name.helpers import get_media_file
845+from python_name_lib.helpers import get_media_file
846
847 import gettext
848 from gettext import gettext as _
849@@ -17,7 +17,7 @@
850 import appindicator
851
852 class Indicator:
853- def __init__(self,window):
854+ def __init__(self, window):
855 self.indicator = appindicator.Indicator('project_name','distributor-logo',appindicator.CATEGORY_APPLICATION_STATUS)
856 self.indicator.set_status(appindicator.STATUS_ACTIVE)
857
858@@ -30,8 +30,7 @@
859
860 self.menu = gtk.Menu()
861
862- # Add items to Menu and connect signals.
863- # Can access methods from bin/python_name using window
864+ # Add items to Menu and connect signals.
865
866 #Adding preferences button
867 #window represents the main Window object of your app
868
869=== renamed file 'data/templates/ubuntu-application/test/apport/BaseTestProjectWindow.py.no_lpi' => 'data/templates/ubuntu-application/test/apport/TestProjectWindow.py.no_lpi'
870=== modified file 'data/templates/ubuntu-application/test/apport/apport.sh'
871--- data/templates/ubuntu-application/test/apport/apport.sh 2010-11-29 15:18:46 +0000
872+++ data/templates/ubuntu-application/test/apport/apport.sh 2011-04-01 21:06:39 +0000
873@@ -11,11 +11,11 @@
874
875 cd test-project
876
877-grep LaunchpadIntegration. test_project/BaseTestProjectWindow.py
878+grep LaunchpadIntegration. test_project_lib/Window.py
879 # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, False, True)
880 # LaunchpadIntegration.set_sourcepackagename('test-project')
881
882-grep helpMenu test_project/BaseTestProjectWindow.py
883+grep helpMenu test_project_lib/Window.py
884 # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, False, True)
885
886 quickly configure lp-project gpoweroff
887@@ -24,11 +24,11 @@
888 # Creating new apport crashdb configuration
889 # Creating new apport hooks
890
891-grep LaunchpadIntegration. test_project/BaseTestProjectWindow.py
892+grep LaunchpadIntegration. test_project_lib/Window.py
893 # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, False, True)
894 # LaunchpadIntegration.set_sourcepackagename('test-project')
895
896-grep helpMenu test_project/BaseTestProjectWindow.py
897+grep helpMenu test_project_lib/Window.py
898 # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, False, True)
899
900 bzr status
901@@ -53,11 +53,11 @@
902 # Launchpad connection is ok
903 # Updating project name references in existing apport crashdb configuration
904
905-grep LaunchpadIntegration. test_project/BaseTestProjectWindow.py
906+grep LaunchpadIntegration. test_project_lib/Window.py
907 # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, False, True)
908 # LaunchpadIntegration.set_sourcepackagename('test-project')
909
910-grep helpMenu test_project/BaseTestProjectWindow.py
911+grep helpMenu test_project_lib/Window.py
912 # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, False, True)
913
914 bzr status
915@@ -118,11 +118,11 @@
916 # Launchpad connection is ok
917 # Updating project name references in existing apport crashdb configuration
918
919-grep LaunchpadIntegration. test_project/BaseTestProjectWindow.py
920+grep LaunchpadIntegration. test_project_lib/Window.py
921 # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, False, True)
922 # LaunchpadIntegration.set_sourcepackagename('test-project')
923
924-grep helpMenu test_project/BaseTestProjectWindow.py
925+grep helpMenu test_project_lib/Window.py
926 # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, False, True)
927
928 bzr status
929@@ -148,11 +148,11 @@
930 # Updating project name references in existing apport crashdb configuration
931 # Creating new apport hooks
932
933-grep LaunchpadIntegration. test_project/BaseTestProjectWindow.py
934+grep LaunchpadIntegration. test_project_lib/Window.py
935 # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, False, True)
936 # LaunchpadIntegration.set_sourcepackagename('test-project')
937
938-grep helpMenu test_project/BaseTestProjectWindow.py
939+grep helpMenu test_project_lib/Window.py
940 # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, False, True)
941
942 cat etc/apport/crashdb.conf.d/test-project-crashdb.conf
943@@ -187,11 +187,11 @@
944 # Launchpad connection is ok
945 # Updating project name references in existing apport crashdb configuration
946
947-grep LaunchpadIntegration. test_project/BaseTestProjectWindow.py
948+grep LaunchpadIntegration. test_project_lib/Window.py
949 # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, False, True)
950 # LaunchpadIntegration.set_sourcepackagename('test-project')
951
952-grep helpMenu test_project/BaseTestProjectWindow.py
953+grep helpMenu test_project_lib/Window.py
954 # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, False, True)
955
956 cat etc/apport/crashdb.conf.d/test-project-crashdb.conf
957@@ -315,11 +315,11 @@
958 # Creating new apport hooks
959 # WARNING: can't update your project to support /opt. This doesn't matter if you don't plan to submit your project to the application review board. Cause is: os.putenv('PYTHONPATH', PROJECT_ROOT_DIRECTORY) # for subprocesses was not found in the file /tmp/test-project/bin/test-project.
960
961-grep LaunchpadIntegration. test_project/BaseTestProjectWindow.py
962+grep LaunchpadIntegration. test_project_lib/Window.py
963 # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, False, True)
964 # LaunchpadIntegration.set_sourcepackagename('test-project')
965
966-grep helpMenu test_project/BaseTestProjectWindow.py
967+grep helpMenu test_project_lib/Window.py
968 # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, False, True)
969
970 cat etc/apport/crashdb.conf.d/test-project-crashdb.conf
971@@ -349,7 +349,7 @@
972 # report['ThirdParty'] = 'True'
973 # report['CrashDB'] = 'test_project'
974
975-cp "$TEST_SCRIPT_DIR/BaseTestProjectWindow.py.no_lpi" ./test_project/BaseTestProjectWindow.py
976+cp "$TEST_SCRIPT_DIR/TestProjectWindow.py.no_lpi" ./test_project_lib/Window.py
977
978 cp "$TEST_SCRIPT_DIR/TestProjectWindow.ui.renamed_help_menu" ./data/ui/TestProjectWindow.ui
979
980@@ -357,9 +357,9 @@
981
982 rm -rf etc
983
984-grep LaunchpadIntegration. test_project/BaseTestProjectWindow.py
985+grep LaunchpadIntegration. test_project_lib/Window.py
986
987-grep helpMenu test_project/BaseTestProjectWindow.py
988+grep helpMenu test_project_lib/Window.py
989
990 quickly upgrade 0.3 0.4
991 # Adding launchpad integration to existing application
992@@ -367,11 +367,11 @@
993 # Creating new apport hooks
994 # WARNING: can't update your project to support /opt. This doesn't matter if you don't plan to submit your project to the application review board. Cause is: os.putenv('PYTHONPATH', PROJECT_ROOT_DIRECTORY) # for subprocesses was not found in the file /tmp/test-project/bin/test-project.
995
996-grep LaunchpadIntegration. test_project/BaseTestProjectWindow.py
997+grep LaunchpadIntegration. test_project_lib/Window.py
998 # LaunchpadIntegration.add_items(self.ui.differentHelpMenu, 1, False, True)
999 # LaunchpadIntegration.set_sourcepackagename('test-project')
1000
1001-cp "$TEST_SCRIPT_DIR/BaseTestProjectWindow.py.no_lpi" ./test_project/BaseTestProjectWindow.py
1002+cp "$TEST_SCRIPT_DIR/TestProjectWindow.py.no_lpi" ./test_project_lib/Window.py
1003
1004 cp "$TEST_SCRIPT_DIR/TestProjectWindow.ui.no_gtk-about" ./data/ui/TestProjectWindow.ui
1005
1006@@ -379,16 +379,16 @@
1007
1008 rm -rf etc
1009
1010-grep LaunchpadIntegration. test_project/BaseTestProjectWindow.py
1011+grep LaunchpadIntegration. test_project_lib/Window.py
1012
1013-grep helpMenu test_project/BaseTestProjectWindow.py
1014+grep helpMenu test_project_lib/Window.py
1015
1016 grep gtk-about data/ui/TestProjectWindow.ui
1017
1018 bzr commit -m "Committing after removing all lpi integration"
1019 # Committing to: /tmp/test-project/
1020 # modified data/ui/TestProjectWindow.ui
1021-# modified test_project/BaseTestProjectWindow.py
1022+# modified test_project_lib/Window.py
1023 # Committed revision 6.
1024
1025 quickly upgrade 0.3 0.4
1026@@ -396,22 +396,22 @@
1027 # Creating new apport hooks
1028 # WARNING: can't update your project to support /opt. This doesn't matter if you don't plan to submit your project to the application review board. Cause is: os.putenv('PYTHONPATH', PROJECT_ROOT_DIRECTORY) # for subprocesses was not found in the file /tmp/test-project/bin/test-project.
1029
1030-grep LaunchpadIntegration. test_project/BaseTestProjectWindow.py
1031+grep LaunchpadIntegration. test_project_lib/Window.py
1032
1033-grep helpMenu test_project/BaseTestProjectWindow.py
1034+grep helpMenu test_project_lib/Window.py
1035
1036 bzr status
1037 # unknown:
1038 # apport/
1039 # etc/
1040
1041-cp "$TEST_SCRIPT_DIR/BaseTestProjectWindow.py.no_lpi" ./test_project/BaseTestProjectWindow.py
1042+cp "$TEST_SCRIPT_DIR/TestProjectWindow.py.no_lpi" ./test_project_lib/Window.py
1043
1044 rm ./data/ui/TestProjectWindow.ui
1045
1046-grep LaunchpadIntegration. test_project/BaseTestProjectWindow.py
1047+grep LaunchpadIntegration. test_project_lib/Window.py
1048
1049-grep helpMenu test_project/BaseTestProjectWindow.py
1050+grep helpMenu test_project_lib/Window.py
1051
1052 quickly upgrade 0.3 0.4
1053 # WARNING: can't update your project to support /opt. This doesn't matter if you don't plan to submit your project to the application review board. Cause is: os.putenv('PYTHONPATH', PROJECT_ROOT_DIRECTORY) # for subprocesses was not found in the file /tmp/test-project/bin/test-project.
1054
1055=== modified file 'data/templates/ubuntu-application/test/builder/builder.py'
1056--- data/templates/ubuntu-application/test/builder/builder.py 2010-12-18 20:05:13 +0000
1057+++ data/templates/ubuntu-application/test/builder/builder.py 2011-04-01 21:06:39 +0000
1058@@ -10,11 +10,11 @@
1059 proj_root = os.path.abspath(os.path.join(os.path.dirname(__file__),"..","..","project_root"))
1060 sys.path.insert(0, proj_root)
1061
1062-from python import Builder
1063+from python_lib import Builder
1064
1065 # Clean up after ourselves
1066-os.remove(os.path.join(proj_root, 'python', '__init__.pyc'))
1067-os.remove(os.path.join(proj_root, 'python', 'Builder.pyc'))
1068+os.remove(os.path.join(proj_root, 'python_lib', '__init__.pyc'))
1069+os.remove(os.path.join(proj_root, 'python_lib', 'Builder.pyc'))
1070
1071 # alias belongs in helpers, but it cannot be imported
1072 def alias(alternative_function_name):
1073@@ -32,7 +32,7 @@
1074 def test_alias_is_in_helpers(self):
1075 # instead of importing alias check we have an exact copy
1076 str_alias = inspect.getsource(alias)
1077- fp = open(os.path.join( proj_root, 'python', 'helpers.py'), 'r')
1078+ fp = open(os.path.join(proj_root, 'python_lib', 'helpers.py'), 'r')
1079 str_helpers = fp.read()
1080 fp.close()
1081
1082
1083=== modified file 'data/templates/ubuntu-application/test/filelist.sh'
1084--- data/templates/ubuntu-application/test/filelist.sh 2011-03-02 22:59:32 +0000
1085+++ data/templates/ubuntu-application/test/filelist.sh 2011-04-01 21:06:39 +0000
1086@@ -40,13 +40,18 @@
1087 # test-project.desktop.in
1088 # test_project/
1089 # test_project/AboutTestProjectDialog.py
1090-# test_project/BaseTestProjectWindow.py
1091-# test_project/Builder.py
1092 # test_project/PreferencesTestProjectDialog.py
1093+# test_project/TestProjectWindow.py
1094 # test_project/__init__.py
1095-# test_project/helpers.py
1096-# test_project/preferences.py
1097-# test_project/test_projectconfig.py
1098+# test_project_lib/
1099+# test_project_lib/AboutDialog.py
1100+# test_project_lib/Builder.py
1101+# test_project_lib/PreferencesDialog.py
1102+# test_project_lib/Window.py
1103+# test_project_lib/__init__.py
1104+# test_project_lib/helpers.py
1105+# test_project_lib/preferences.py
1106+# test_project_lib/test_projectconfig.py
1107 # tests/
1108 # tests/test_example.py
1109 # tests/test_lint.py
1110
1111=== modified file 'data/templates/ubuntu-application/test/preferences.py'
1112--- data/templates/ubuntu-application/test/preferences.py 2011-02-22 20:43:24 +0000
1113+++ data/templates/ubuntu-application/test/preferences.py 2011-04-01 21:06:39 +0000
1114@@ -1,16 +1,18 @@
1115 import unittest
1116 import os
1117 import sys
1118+import glob
1119
1120-proj_root = os.path.abspath(os.path.join(os.path.dirname(__file__),"..","project_root", "python"))
1121+proj_root = os.path.abspath(os.path.join(os.path.dirname(__file__),"..","project_root"))
1122 sys.path.insert(0, proj_root)
1123 import logging
1124 logging.debug(sys.path[0])
1125
1126-from preferences import User_dict, preferences
1127+from python_lib.preferences import User_dict, preferences
1128
1129 # Clean up after ourselves
1130-os.remove(os.path.join(proj_root, 'preferences.pyc'))
1131+for f in glob.glob(os.path.join(proj_root, 'python_lib', '*.pyc')):
1132+ os.remove(f)
1133
1134 class TestUser_dict(unittest.TestCase):
1135
1136
1137=== modified file 'data/templates/ubuntu-cli/project_root/bin/project_name'
1138--- data/templates/ubuntu-cli/project_root/bin/project_name 2011-03-30 17:57:06 +0000
1139+++ data/templates/ubuntu-cli/project_root/bin/project_name 2011-04-01 21:06:39 +0000
1140@@ -4,15 +4,9 @@
1141 # This file is in the public domain
1142 ### END LICENSE
1143
1144-import logging
1145-import optparse
1146 import os
1147 import sys
1148
1149-import gettext
1150-from gettext import gettext as _
1151-gettext.textdomain('project_name')
1152-
1153 # Add project root directory (enable symlink, and trunk execution).
1154 PROJECT_ROOT_DIRECTORY = os.path.abspath(
1155 os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0]))))
1156@@ -22,41 +16,5 @@
1157 sys.path.insert(0, PROJECT_ROOT_DIRECTORY)
1158 os.putenv('PYTHONPATH', PROJECT_ROOT_DIRECTORY) # for subprocesses
1159
1160-from python_name import python_nameconfig
1161-
1162-LEVELS = ( logging.ERROR,
1163- logging.WARNING,
1164- logging.INFO,
1165- logging.DEBUG,
1166- )
1167-
1168-if __name__ == "__main__":
1169-
1170- version = python_nameconfig.__version__
1171- # Support for command line options.
1172- usage = _("project_name [options]")
1173- parser = optparse.OptionParser(version="%%prog %s" % version, usage=usage)
1174- parser.add_option('-d', '--debug', dest='debug_mode', action='store_true',
1175- help=_('Print the maximum debugging info (implies -vv)'))
1176- parser.add_option('-v', '--verbose', dest='logging_level', action='count',
1177- help=_('set error_level output to warning, info, and then debug'))
1178- # exemple of silly CLI option
1179- parser.add_option("-f", "--foo", action="store", dest="foo",
1180- help=_("foo should be assigned to bar"))
1181- parser.set_defaults(logging_level=0, foo=None)
1182- (options, args) = parser.parse_args()
1183-
1184- # set the verbosity
1185- if options.debug_mode:
1186- options.logging_level = 3
1187- logging.basicConfig(level=LEVELS[options.logging_level], format='%(asctime)s %(levelname)s %(message)s')
1188-
1189-
1190- # this is the easter egg (:
1191- if options.foo == 'bar':
1192- logging.warning(_('easter egg found'))
1193- print(_("Schweet"))
1194-
1195- # Run your cli application there.
1196- print _("I'm launched and my args are: %s") % (" ".join(args))
1197- logging.debug(_('end of prog'))
1198+import python_name
1199+python_name.main()
1200
1201=== modified file 'data/templates/ubuntu-cli/project_root/python/__init__.py'
1202--- data/templates/ubuntu-cli/project_root/python/__init__.py 2010-02-05 08:05:51 +0000
1203+++ data/templates/ubuntu-cli/project_root/python/__init__.py 2011-04-01 21:06:39 +0000
1204@@ -0,0 +1,48 @@
1205+import logging
1206+import optparse
1207+
1208+import gettext
1209+from gettext import gettext as _
1210+gettext.textdomain('project_name')
1211+
1212+from python_name import python_nameconfig
1213+
1214+LEVELS = ( logging.ERROR,
1215+ logging.WARNING,
1216+ logging.INFO,
1217+ logging.DEBUG,
1218+ )
1219+
1220+def main():
1221+ version = python_nameconfig.__version__
1222+ # Support for command line options.
1223+ usage = _("project_name [options]")
1224+ parser = optparse.OptionParser(version="%%prog %s" % version, usage=usage)
1225+ parser.add_option('-d', '--debug', dest='debug_mode', action='store_true',
1226+ help=_('Print the maximum debugging info (implies -vv)'))
1227+ parser.add_option('-v', '--verbose', dest='logging_level', action='count',
1228+ help=_('set error_level output to warning, info, and then debug'))
1229+ # exemple of silly CLI option
1230+ parser.add_option("-f", "--foo", action="store", dest="foo",
1231+ help=_("foo should be assigned to bar"))
1232+ parser.set_defaults(logging_level=0, foo=None)
1233+ (options, args) = parser.parse_args()
1234+
1235+ # set the verbosity
1236+ if options.debug_mode:
1237+ options.logging_level = 3
1238+ logging.basicConfig(level=LEVELS[options.logging_level], format='%(asctime)s %(levelname)s %(message)s')
1239+
1240+
1241+ # this is the easter egg (:
1242+ if options.foo == 'bar':
1243+ logging.warning(_('easter egg found'))
1244+ print(_("Schweet"))
1245+
1246+ # Run your cli application there.
1247+ print _("I'm launched and my args are: %s") % (" ".join(args))
1248+ logging.debug(_('end of prog'))
1249+
1250+
1251+if __name__ == "__main__":
1252+ main()
1253
1254=== modified file 'data/templates/ubuntu-pygame/project_root/bin/project_name'
1255--- data/templates/ubuntu-pygame/project_root/bin/project_name 2011-02-21 06:06:37 +0000
1256+++ data/templates/ubuntu-pygame/project_root/bin/project_name 2011-04-01 21:06:39 +0000
1257@@ -1,6 +1,5 @@
1258 #! /usr/bin/env python
1259 import os, sys
1260-import pygame, random
1261
1262 # Add project root directory (enable symlink, and trunk execution).
1263 PROJECT_ROOT_DIRECTORY = os.path.abspath(
1264@@ -11,239 +10,5 @@
1265 sys.path.insert(0, PROJECT_ROOT_DIRECTORY)
1266 os.putenv('PYTHONPATH', PROJECT_ROOT_DIRECTORY) # for subprocesses
1267
1268-#import classes from the python_name library
1269-from python_name.base_sprite import BaseSprite
1270-from python_name.guy import Guy
1271-from python_name.enemy import Enemy
1272-from python_name.homingmissle import HomingMissle
1273-from python_name.game import Game
1274-from python_name import hiscores
1275-import python_name.python_nameconfig
1276-
1277-#set up translations
1278-import gettext
1279-from gettext import gettext as _
1280-gettext.textdomain('project_name')
1281-
1282-#initialize pygame and ther libraries
1283-pygame.font.init()
1284-pygame.mixer.init()
1285-random.seed()
1286-
1287-sw = python_name.python_nameconfig.screen_width
1288-sh = python_name.python_nameconfig.screen_height
1289-
1290-#setup the display
1291-screen = pygame.display.set_mode((sw, sh))
1292-background = pygame.image.load(python_name.python_nameconfig.background_image)
1293-pygame.mouse.set_visible(False)
1294-
1295-#set up some objects and models
1296-clock = pygame.time.Clock()
1297-font = pygame.font.Font(None, 24)
1298-game = Game()
1299-game.level = 0
1300-
1301-#create the player's guy and some enemies
1302-bullets = pygame.sprite.RenderUpdates()
1303-guys = pygame.sprite.RenderUpdates()
1304-enemies = pygame.sprite.RenderUpdates()
1305-g = Guy(bullets)
1306-guys.add(g)
1307-
1308-def update_hiscore_screen():
1309- """Update the hiscore screen."""
1310- hiscores_size = python_name.python_nameconfig.hiscores_size
1311- hiscores.screen = hiscores.hiscores_screen(hiscores_size)
1312- screen_center = screen.get_rect().center
1313- hiscores.pos = hiscores.screen.get_rect(center=screen_center)
1314-
1315-def next_level():
1316- """next_level - go to the next game level
1317- after completing the previous level
1318-
1319- """
1320-
1321- game.level += 1
1322- enemies.empty()
1323-
1324- #TODO: set up enemies here
1325- #You can add more enemies or use different enemies
1326- #depening on the level
1327- for i in xrange(0,1):
1328- enemies.add(Enemy())
1329- enemies.add(HomingMissle(g,python_name.python_nameconfig.homing_missle_image))
1330-
1331-def reset_level():
1332- """reset_level - reset the current level after the player's
1333- guy has died, and is done exploding
1334-
1335- """
1336-
1337- #The guy is done exploding, so decrement the level and
1338- #and reset the guy
1339- game.lives -= 1
1340- g.explodestage = 0 #he's done exploding
1341- guys.add(g) #make him live again
1342- g.visible = True
1343- g.init_position()
1344-
1345-def controller_tick():
1346- """controller_tick - collect user input and update data
1347-
1348- """
1349-
1350- #handle starting the game or quiting the game if the game
1351- #is over or has not started
1352- if game.lives < 1:
1353- if game.playing:
1354- game.playing = False
1355- hiscores.save_score(game.score, game.level)
1356- update_hiscore_screen()
1357- for event in pygame.event.get():
1358- if event.type == pygame.KEYDOWN:
1359- if event.key == pygame.K_ESCAPE:
1360- return 0
1361- if event.key == 13:
1362- game.reset()
1363- next_level()
1364- return 1
1365- if event.key == pygame.K_F11:
1366- pygame.display.toggle_fullscreen()
1367- return 1
1368-
1369- #if the guy has been killed and the explosion is over
1370- #reset the level
1371- if(not g.alive() and not g.exploding):
1372- reset_level()
1373-
1374- #if all the enemies are kill and there are more lives,
1375- #go to the next level
1376- if len(enemies) == 0 and not game.lives < 1:
1377- next_level()
1378-
1379- #respond to user input if the game is not over
1380- for event in pygame.event.get():
1381- if event.type == pygame.QUIT:
1382- return 0
1383-
1384- #key down events, typically initiate actions
1385- if event.type == pygame.KEYDOWN:
1386- if event.key == pygame.K_ESCAPE:
1387- return 0
1388-
1389- #pause or unpause
1390- if event.key == pygame.K_p:
1391- game.paused = not game.paused
1392-
1393- #control the guy
1394- if not game.paused:
1395- if event.key == pygame.K_f:
1396- g.start_rotation_right()
1397- if event.key == pygame.K_s:
1398- g.start_rotation_left()
1399- if event.key == pygame.K_l:
1400- g.accelerate()
1401- if event.key == pygame.K_j:
1402- g.shoot()
1403- if event.key == pygame.K_SPACE:
1404- g.hyperspace()
1405-
1406- #key up events, typically stop actions
1407- if event.type == pygame.KEYUP:
1408- if event.key == pygame.K_F11:
1409- pygame.display.toggle_fullscreen()
1410- if event.key == pygame.K_f:
1411- g.stop_rotating_right()
1412- if event.key == pygame.K_s:
1413- g.stop_rotating_left()
1414- if event.key == pygame.K_l:
1415- g.stop_acceleration()
1416-
1417-def update_sprites():
1418- """update_sprites - call update() for all sprites"""
1419- guys.update()
1420- bullets.update()
1421- enemies.update()
1422-
1423-def view_tick():
1424- """view_tick - visually update the screen"""
1425-
1426- #draw the background
1427- screen.blit(background, [0,0])
1428-
1429- #draw the player's guy and bullets
1430- if g.visible:
1431- screen.blit(g.image, g.rect)
1432- bullets.draw(screen)
1433-
1434- #draw enemies
1435- enemies.draw(screen)
1436-
1437- #update the scoreboard
1438- scoretxt = font.render("score: " + str(game.score), 1, (100, 100, 100))
1439- scorepos = pygame.Rect(35,15,scoretxt.get_rect().height,scoretxt.get_rect().width)
1440- leveltxt = font.render("level: " + str(game.level), 1, (100, 100, 100))
1441- levelpos = pygame.Rect(35,35,leveltxt.get_rect().height,leveltxt.get_rect().width)
1442- livestxt = font.render("lives: " + str(game.lives), 1, (100, 100, 100))
1443- livespos = pygame.Rect(35,55,livestxt.get_rect().height,livestxt.get_rect().width)
1444-
1445- screen.blit(scoretxt, scorepos)
1446- screen.blit(leveltxt, levelpos)
1447- screen.blit(livestxt, livespos)
1448- if not game.playing:
1449- screen.blit(hiscores.screen, hiscores.pos)
1450-
1451-
1452- #now show the new drawing
1453- pygame.display.flip()
1454-
1455-def check_collisions():
1456- """check_collisions - check for sprite collisions and update
1457- as necessary.
1458-
1459- """
1460-
1461- #if the player's guy is not alive, don't let it collide
1462- #this occurs if he is exploding
1463- #otherwise, if he collides with enemies, explode them both
1464- if g.alive():
1465- e = pygame.sprite.spritecollideany(g, enemies)
1466- if e != None:
1467- if e.alive():
1468- g.explode()
1469- e.explode()
1470-
1471- #check if any enemies got hit by any bullets
1472- hits_dict = pygame.sprite.groupcollide(bullets, enemies, False, False)
1473- if len(hits_dict) != 0:
1474- for b in hits_dict:
1475- for e in hits_dict[b]:
1476- if e.alive():
1477- e.explode()
1478- game.increase_score(e.points)
1479- b.explode()
1480-
1481-def main():
1482- """main - function to start the main loop. Program ends
1483- when main() returns.
1484-
1485- """
1486-
1487- update_hiscore_screen()
1488- while 1:
1489- #set the clock to tick 15 times per second
1490- clock.tick(15)
1491-
1492- #check for user input, quit if necessary
1493- if controller_tick() == 0:
1494- return
1495-
1496- #let the game run for a frame
1497- if not game.paused:
1498- update_sprites()
1499- view_tick()
1500- check_collisions()
1501-
1502-#start the main loop
1503-main()
1504+import python_name
1505+python_name.main()
1506
1507=== modified file 'data/templates/ubuntu-pygame/project_root/python/__init__.py'
1508--- data/templates/ubuntu-pygame/project_root/python/__init__.py 2010-03-29 16:23:32 +0000
1509+++ data/templates/ubuntu-pygame/project_root/python/__init__.py 2011-04-01 21:06:39 +0000
1510@@ -0,0 +1,237 @@
1511+#! /usr/bin/env python
1512+import pygame, random
1513+
1514+#import classes from the python_name library
1515+from python_name.base_sprite import BaseSprite
1516+from python_name.guy import Guy
1517+from python_name.enemy import Enemy
1518+from python_name.homingmissle import HomingMissle
1519+from python_name.game import Game
1520+from python_name import hiscores
1521+import python_name.python_nameconfig
1522+
1523+#set up translations
1524+import gettext
1525+from gettext import gettext as _
1526+gettext.textdomain('project_name')
1527+
1528+#initialize pygame and ther libraries
1529+pygame.font.init()
1530+pygame.mixer.init()
1531+random.seed()
1532+
1533+sw = python_name.python_nameconfig.screen_width
1534+sh = python_name.python_nameconfig.screen_height
1535+
1536+#setup the display
1537+screen = pygame.display.set_mode((sw, sh))
1538+background = pygame.image.load(python_name.python_nameconfig.background_image)
1539+pygame.mouse.set_visible(False)
1540+
1541+#set up some objects and models
1542+clock = pygame.time.Clock()
1543+font = pygame.font.Font(None, 24)
1544+game = Game()
1545+game.level = 0
1546+
1547+#create the player's guy and some enemies
1548+bullets = pygame.sprite.RenderUpdates()
1549+guys = pygame.sprite.RenderUpdates()
1550+enemies = pygame.sprite.RenderUpdates()
1551+g = Guy(bullets)
1552+guys.add(g)
1553+
1554+def update_hiscore_screen():
1555+ """Update the hiscore screen."""
1556+ hiscores_size = python_name.python_nameconfig.hiscores_size
1557+ hiscores.screen = hiscores.hiscores_screen(hiscores_size)
1558+ screen_center = screen.get_rect().center
1559+ hiscores.pos = hiscores.screen.get_rect(center=screen_center)
1560+
1561+def next_level():
1562+ """next_level - go to the next game level
1563+ after completing the previous level
1564+
1565+ """
1566+
1567+ game.level += 1
1568+ enemies.empty()
1569+
1570+ #TODO: set up enemies here
1571+ #You can add more enemies or use different enemies
1572+ #depening on the level
1573+ for i in xrange(0,1):
1574+ enemies.add(Enemy())
1575+ enemies.add(HomingMissle(g,python_name.python_nameconfig.homing_missle_image))
1576+
1577+def reset_level():
1578+ """reset_level - reset the current level after the player's
1579+ guy has died, and is done exploding
1580+
1581+ """
1582+
1583+ #The guy is done exploding, so decrement the level and
1584+ #and reset the guy
1585+ game.lives -= 1
1586+ g.explodestage = 0 #he's done exploding
1587+ guys.add(g) #make him live again
1588+ g.visible = True
1589+ g.init_position()
1590+
1591+def controller_tick():
1592+ """controller_tick - collect user input and update data
1593+
1594+ """
1595+
1596+ #handle starting the game or quiting the game if the game
1597+ #is over or has not started
1598+ if game.lives < 1:
1599+ if game.playing:
1600+ game.playing = False
1601+ hiscores.save_score(game.score, game.level)
1602+ update_hiscore_screen()
1603+ for event in pygame.event.get():
1604+ if event.type == pygame.KEYDOWN:
1605+ if event.key == pygame.K_ESCAPE:
1606+ return 0
1607+ if event.key == 13:
1608+ game.reset()
1609+ next_level()
1610+ return 1
1611+ if event.key == pygame.K_F11:
1612+ pygame.display.toggle_fullscreen()
1613+ return 1
1614+
1615+ #if the guy has been killed and the explosion is over
1616+ #reset the level
1617+ if(not g.alive() and not g.exploding):
1618+ reset_level()
1619+
1620+ #if all the enemies are kill and there are more lives,
1621+ #go to the next level
1622+ if len(enemies) == 0 and not game.lives < 1:
1623+ next_level()
1624+
1625+ #respond to user input if the game is not over
1626+ for event in pygame.event.get():
1627+ if event.type == pygame.QUIT:
1628+ return 0
1629+
1630+ #key down events, typically initiate actions
1631+ if event.type == pygame.KEYDOWN:
1632+ if event.key == pygame.K_ESCAPE:
1633+ return 0
1634+
1635+ #pause or unpause
1636+ if event.key == pygame.K_p:
1637+ game.paused = not game.paused
1638+
1639+ #control the guy
1640+ if not game.paused:
1641+ if event.key == pygame.K_f:
1642+ g.start_rotation_right()
1643+ if event.key == pygame.K_s:
1644+ g.start_rotation_left()
1645+ if event.key == pygame.K_l:
1646+ g.accelerate()
1647+ if event.key == pygame.K_j:
1648+ g.shoot()
1649+ if event.key == pygame.K_SPACE:
1650+ g.hyperspace()
1651+
1652+ #key up events, typically stop actions
1653+ if event.type == pygame.KEYUP:
1654+ if event.key == pygame.K_F11:
1655+ pygame.display.toggle_fullscreen()
1656+ if event.key == pygame.K_f:
1657+ g.stop_rotating_right()
1658+ if event.key == pygame.K_s:
1659+ g.stop_rotating_left()
1660+ if event.key == pygame.K_l:
1661+ g.stop_acceleration()
1662+
1663+def update_sprites():
1664+ """update_sprites - call update() for all sprites"""
1665+ guys.update()
1666+ bullets.update()
1667+ enemies.update()
1668+
1669+def view_tick():
1670+ """view_tick - visually update the screen"""
1671+
1672+ #draw the background
1673+ screen.blit(background, [0,0])
1674+
1675+ #draw the player's guy and bullets
1676+ if g.visible:
1677+ screen.blit(g.image, g.rect)
1678+ bullets.draw(screen)
1679+
1680+ #draw enemies
1681+ enemies.draw(screen)
1682+
1683+ #update the scoreboard
1684+ scoretxt = font.render("score: " + str(game.score), 1, (100, 100, 100))
1685+ scorepos = pygame.Rect(35,15,scoretxt.get_rect().height,scoretxt.get_rect().width)
1686+ leveltxt = font.render("level: " + str(game.level), 1, (100, 100, 100))
1687+ levelpos = pygame.Rect(35,35,leveltxt.get_rect().height,leveltxt.get_rect().width)
1688+ livestxt = font.render("lives: " + str(game.lives), 1, (100, 100, 100))
1689+ livespos = pygame.Rect(35,55,livestxt.get_rect().height,livestxt.get_rect().width)
1690+
1691+ screen.blit(scoretxt, scorepos)
1692+ screen.blit(leveltxt, levelpos)
1693+ screen.blit(livestxt, livespos)
1694+ if not game.playing:
1695+ screen.blit(hiscores.screen, hiscores.pos)
1696+
1697+
1698+ #now show the new drawing
1699+ pygame.display.flip()
1700+
1701+def check_collisions():
1702+ """check_collisions - check for sprite collisions and update
1703+ as necessary.
1704+
1705+ """
1706+
1707+ #if the player's guy is not alive, don't let it collide
1708+ #this occurs if he is exploding
1709+ #otherwise, if he collides with enemies, explode them both
1710+ if g.alive():
1711+ e = pygame.sprite.spritecollideany(g, enemies)
1712+ if e != None:
1713+ if e.alive():
1714+ g.explode()
1715+ e.explode()
1716+
1717+ #check if any enemies got hit by any bullets
1718+ hits_dict = pygame.sprite.groupcollide(bullets, enemies, False, False)
1719+ if len(hits_dict) != 0:
1720+ for b in hits_dict:
1721+ for e in hits_dict[b]:
1722+ if e.alive():
1723+ e.explode()
1724+ game.increase_score(e.points)
1725+ b.explode()
1726+
1727+def main():
1728+ """main - function to start the main loop. Program ends
1729+ when main() returns.
1730+
1731+ """
1732+
1733+ update_hiscore_screen()
1734+ while 1:
1735+ #set the clock to tick 15 times per second
1736+ clock.tick(15)
1737+
1738+ #check for user input, quit if necessary
1739+ if controller_tick() == 0:
1740+ return
1741+
1742+ #let the game run for a frame
1743+ if not game.paused:
1744+ update_sprites()
1745+ view_tick()
1746+ check_collisions()
1747+
1748
1749=== modified file 'quickly/launchpadaccess.py'
1750--- quickly/launchpadaccess.py 2010-10-13 19:07:55 +0000
1751+++ quickly/launchpadaccess.py 2011-04-01 21:06:39 +0000
1752@@ -71,60 +71,28 @@
1753 launchpad = None
1754 return_code = 0
1755
1756- # setup right cache, credentials and server
1757- lp_cred_dir = os.path.expanduser("~/.cache/lp_credentials/")
1758- if not os.path.isdir(lp_cred_dir):
1759- os.makedirs(lp_cred_dir)
1760- os.chmod(lp_cred_dir, 0700)
1761-
1762- lp_cache_dir = os.path.expanduser('~/.cache/lp_credentials/lp-cache/')
1763- if not os.path.isdir(lp_cache_dir):
1764- os.makedirs(lp_cache_dir)
1765-
1766 # check which server to address
1767 if lp_server == "staging":
1768- lp_cred = lp_cred_dir + "quickly-cred-staging"
1769 SERVICE_ROOT = STAGING_SERVICE_ROOT
1770 print _("WARNING: you are using staging and not launchpad real production server")
1771 else:
1772- lp_cred = lp_cred_dir + "quickly-cred"
1773 SERVICE_ROOT = EDGE_SERVICE_ROOT
1774
1775 # load stored LP credentials
1776- try:
1777- if interactive:
1778- print _("Get Launchpad Settings")
1779- lp_cred_file = None
1780- lp_cred_file = open(lp_cred, 'r')
1781- credentials = Credentials()
1782- credentials.load(lp_cred_file)
1783- lp_cred_file.close()
1784- try:
1785- launchpad = Launchpad(credentials, SERVICE_ROOT, lp_cache_dir)
1786- except httplib2.ServerNotFoundError, e:
1787- raise launchpad_connection_error(e)
1788- except (IOError, HTTPError):
1789- if interactive:
1790- # case where autorization on Launchpad was removed
1791- if lp_cred_file:
1792- os.remove(lp_cred_file.name)
1793- print _('Previous Launchpad values seems to have been removed.')
1794- else:
1795- print _('Initial Launchpad binding.')
1796- launchpad = Launchpad.get_token_and_login(_('Quickly'), SERVICE_ROOT, lp_cache_dir, allow_access_levels=["WRITE_PRIVATE"])
1797- lp_cred_file = open(lp_cred, 'w')
1798- launchpad.credentials.save(lp_cred_file)
1799- lp_cred_file.close()
1800+ if interactive:
1801+ print _("Get Launchpad Settings")
1802+ launchpad = Launchpad.login_with(_('Quickly'),
1803+ service_root=SERVICE_ROOT,
1804+ allow_access_levels=["WRITE_PRIVATE"])
1805
1806- # try to setup bzr
1807- me = launchpad.me
1808- (return_code, suggestion) = bzrbinding.bzr_set_login(me.display_name, me.preferred_email_address.email, me.name)
1809+ # try to setup bzr
1810+ me = launchpad.me
1811+ (return_code, suggestion) = bzrbinding.bzr_set_login(me.display_name, me.preferred_email_address.email, me.name)
1812
1813 if interactive:
1814 if launchpad is None or return_code != 0:
1815 if suggestion is None:
1816 suggestion = _("Unknown reason")
1817- os.remove(lp_cred)
1818 raise launchpad_connection_error(_("Couldn't setup Launchpad for quickly ; %s") % suggestion)
1819 print _("Launchpad connection is ok")
1820

Subscribers

People subscribed via source and target branches