Merge lp:~mterry/quickly/small-refactor into lp:quickly

Proposed by Michael Terry
Status: Needs review
Proposed branch: lp:~mterry/quickly/small-refactor
Merge into: lp:quickly
Diff against target: 753 lines (+207/-192)
14 files modified
data/templates/ubuntu-application/configure.py (+12/-15)
data/templates/ubuntu-application/internal/bzrutils.py (+0/-37)
data/templates/ubuntu-application/package.py (+2/-1)
data/templates/ubuntu-application/release.py (+16/-17)
data/templates/ubuntu-application/share.py (+5/-4)
data/templates/ubuntu-application/submitubuntu.py (+16/-17)
data/templates/ubuntu-application/test/apportutils.py (+7/-7)
data/templates/ubuntu-application/upgrade.py (+3/-4)
quickly/lp/__init__.py (+18/-0)
quickly/lp/access.py (+3/-84)
quickly/lp/bzr.py (+20/-1)
quickly/lp/project.py (+82/-0)
quickly/ubuntu/__init__.py (+18/-0)
quickly/ubuntu/packaging.py (+5/-5)
To merge this branch: bzr merge lp:~mterry/quickly/small-refactor
Reviewer Review Type Date Requested Status
Quickly Developers Pending
Review via email: mp+44606@code.launchpad.net

Description of the change

This is a bit of a refactor to pull some code from ubuntu-application's 'internal' module into the 'quickly' module.

This started based on the quickly-talk thread about how best to enable non-ubuntu templates. This doesn't directly aid that goal, as most of the stuff pulled out is for LP or Ubuntu integration. But it is a proof of concept.

After this is discussed/approved, we can perhaps pull out some of the python code to be more generic too.

To post a comment you must log in.

Unmerged revisions

581. By Michael Terry

move packaging and apport modules to a new quickly.ubuntu module

580. By Michael Terry

create and use quickly.lp

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/templates/ubuntu-application/configure.py'
2--- data/templates/ubuntu-application/configure.py 2010-10-18 18:39:04 +0000
3+++ data/templates/ubuntu-application/configure.py 2010-12-23 18:15:10 +0000
4@@ -20,13 +20,10 @@
5 import sys
6 import subprocess
7
8-import internal.apportutils
9-
10-from internal import quicklyutils, packaging
11-from internal import bzrutils
12+from internal import quicklyutils
13 from quickly import configurationhandler, templatetools
14-from quickly import launchpadaccess
15-
16+from quickly.ubuntu import apport, packaging
17+import quickly.lp as lp
18
19 import gettext
20 from gettext import gettext as _
21@@ -73,8 +70,8 @@
22 if argv[1] == "lp-project":
23 # connect to LP
24 try:
25- launchpad = launchpadaccess.initialize_lpi()
26- except launchpadaccess.launchpad_connection_error, e:
27+ launchpad = lp.access.initialize_lpi()
28+ except lp.access.launchpad_connection_error, e:
29 print(e)
30 sys.exit(1)
31
32@@ -90,13 +87,13 @@
33 previous_lp_project_name = configurationhandler.project_config.get('lp_id', None)
34 quickly_project_name = configurationhandler.project_config.get('project', None)
35 try:
36- project = launchpadaccess.link_project(launchpad, "Change your launchpad project:", project_name)
37- internal.apportutils.update_apport(quickly_project_name, previous_lp_project_name, project.name)
38- except launchpadaccess.launchpad_project_error, e:
39+ project = lp.project.link_project(launchpad, "Change your launchpad project:", project_name)
40+ apport.update_apport(quickly_project_name, previous_lp_project_name, project.name)
41+ except lp.access.launchpad_project_error, e:
42 print(e)
43 sys.exit(1)
44 # get the project now and save the url into setup.py
45- project_url = launchpadaccess.launchpad_url + '/' + project.name
46+ project_url = lp.access.launchpad_url + '/' + project.name
47 quicklyutils.set_setup_value('url', project_url)
48 about_dialog_file_name = quicklyutils.get_about_file_name()
49 if about_dialog_file_name:
50@@ -112,8 +109,8 @@
51
52 # connect to LP
53 try:
54- launchpad = launchpadaccess.initialize_lpi()
55- except launchpadaccess.launchpad_connection_error, e:
56+ launchpad = lp.access.initialize_lpi()
57+ except lp.access.launchpad_connection_error, e:
58 print(e)
59 sys.exit(1)
60
61@@ -147,7 +144,7 @@
62 if len(argv) != 3:
63 templatetools.print_usage(options['bzr'])
64 sys.exit(4)
65- bzrutils.set_bzrbranch(argv[2])
66+ lp.bzr.set_bzrbranch(argv[2])
67 configurationhandler.saveConfig()
68
69 # add additional dependencies
70
71=== removed file 'data/templates/ubuntu-application/internal/bzrutils.py'
72--- data/templates/ubuntu-application/internal/bzrutils.py 2010-08-13 15:04:05 +0000
73+++ data/templates/ubuntu-application/internal/bzrutils.py 1970-01-01 00:00:00 +0000
74@@ -1,37 +0,0 @@
75-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
76-# Copyright 2010 Didier Roche
77-#
78-# This file is part of Quickly ubuntu-application template
79-#
80-#This program is free software: you can redistribute it and/or modify it
81-#under the terms of the GNU General Public License version 3, as published
82-#by the Free Software Foundation.
83-
84-#This program is distributed in the hope that it will be useful, but
85-#WITHOUT ANY WARRANTY; without even the implied warranties of
86-#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
87-#PURPOSE. See the GNU General Public License for more details.
88-
89-#You should have received a copy of the GNU General Public License along
90-#with this program. If not, see <http://www.gnu.org/licenses/>.
91-
92-from quickly import configurationhandler
93-
94-def set_bzrbranch(bzr_branch):
95- '''set default bzr branch from where to pull and push'''
96-
97- if not configurationhandler.project_config:
98- configurationhandler.loadConfig()
99- configurationhandler.project_config['bzrbranch'] = bzr_branch
100-
101-def get_bzrbranch():
102- '''get default bzr branch from where to pull and push'''
103-
104- if not configurationhandler.project_config:
105- configurationhandler.loadConfig()
106-
107- try:
108- bzr_branch = configurationhandler.project_config['bzrbranch']
109- except KeyError:
110- bzr_branch = None
111- return bzr_branch
112
113=== modified file 'data/templates/ubuntu-application/package.py'
114--- data/templates/ubuntu-application/package.py 2010-10-15 20:26:19 +0000
115+++ data/templates/ubuntu-application/package.py 2010-12-23 18:15:10 +0000
116@@ -23,8 +23,9 @@
117 from gettext import gettext as _
118 gettext.textdomain('quickly')
119
120-from internal import quicklyutils, packaging
121+from internal import quicklyutils
122 from quickly import templatetools, configurationhandler
123+from quickly.ubuntu import packaging
124
125
126 def usage():
127
128=== modified file 'data/templates/ubuntu-application/release.py'
129--- data/templates/ubuntu-application/release.py 2010-10-18 18:39:04 +0000
130+++ data/templates/ubuntu-application/release.py 2010-12-23 18:15:10 +0000
131@@ -21,15 +21,14 @@
132 import subprocess
133 import webbrowser
134
135-from internal import quicklyutils, packaging, launchpad_helper
136-from internal import bzrutils
137+from internal import quicklyutils
138 from quickly import templatetools, configurationhandler, commands
139+from quickly.ubuntu import packaging
140+import quickly.lp as lp
141 import license
142
143 import logging
144
145-from quickly import launchpadaccess
146-
147 import gettext
148 from gettext import gettext as _
149 gettext.textdomain('quickly')
150@@ -113,8 +112,8 @@
151
152 # connect to LP
153 try:
154- launchpad = launchpadaccess.initialize_lpi()
155-except launchpadaccess.launchpad_connection_error, e:
156+ launchpad = lp.access.initialize_lpi()
157+except lp.access.launchpad_connection_error, e:
158 print(e)
159 sys.exit(1)
160
161@@ -127,11 +126,11 @@
162
163 # get the project now and save the url into setup.py
164 try:
165- project = launchpadaccess.get_project(launchpad)
166-except launchpadaccess.launchpad_project_error, e:
167+ project = lp.project.get_project(launchpad)
168+except lp.access.launchpad_project_error, e:
169 print(e)
170 sys.exit(1)
171-project_url = launchpadaccess.launchpad_url + '/' + project.name
172+project_url = lp.access.launchpad_url + '/' + project.name
173 quicklyutils.set_setup_value('url', project_url)
174 about_dialog_file_name = quicklyutils.get_about_file_name()
175 if about_dialog_file_name:
176@@ -234,14 +233,14 @@
177 sys.exit(1)
178
179
180-if (launchpadaccess.lp_server == "staging"):
181+if (lp.access.lp_server == "staging"):
182 bzr_staging = "//staging/"
183 else:
184 bzr_staging = ""
185
186 custom_location_in_info = None
187 branch_location = []
188-custom_location = bzrutils.get_bzrbranch()
189+custom_location = lp.bzr.get_bzrbranch()
190 if custom_location:
191 branch_location = [custom_location]
192 custom_location_in_info = custom_location.replace('lp:', '')
193@@ -282,14 +281,14 @@
194 sys.exit(return_code)
195
196 #create new release_date
197-launchpad_helper.push_tarball_to_launchpad(project, release_version,
198- "../%s_%s.tar.gz" % (project_name,
199- release_version), changelog)
200+lp.project.push_tarball_to_launchpad(project, release_version,
201+ "../%s_%s.tar.gz" % (project_name,
202+ release_version), changelog)
203
204 print _("%s %s released and building on Launchpad. Wait for half an hour and have look at %s.") % (project_name, release_version, ppa_url)
205
206 # as launchpad-open doesn't support staging server, put an url
207-if launchpadaccess.lp_server == "staging":
208- webbrowser.open(launchpadaccess.LAUNCHPAD_CODE_STAGING_URL + '/' + project.name)
209+if lp.access.lp_server == "staging":
210+ webbrowser.open(lp.access.LAUNCHPAD_CODE_STAGING_URL + '/' + project.name)
211 else:
212- webbrowser.open(launchpadaccess.LAUNCHPAD_URL + '/' + project.name)
213+ webbrowser.open(lp.access.LAUNCHPAD_URL + '/' + project.name)
214
215=== modified file 'data/templates/ubuntu-application/share.py'
216--- data/templates/ubuntu-application/share.py 2010-10-18 18:39:04 +0000
217+++ data/templates/ubuntu-application/share.py 2010-12-23 18:15:10 +0000
218@@ -28,8 +28,9 @@
219 gettext.textdomain('quickly')
220
221 from quickly import configurationhandler
222-from internal import quicklyutils, packaging
223-from quickly import launchpadaccess
224+from internal import quicklyutils
225+from quickly.ubuntu import packaging
226+import quickly.lp as lp
227
228 launchpad = None
229 ppa_name = None
230@@ -98,8 +99,8 @@
231
232 # connect to LP
233 try:
234- launchpad = launchpadaccess.initialize_lpi()
235-except launchpadaccess.launchpad_connection_error, e:
236+ launchpad = lp.access.initialize_lpi()
237+except lp.access.launchpad_connection_error, e:
238 print(e)
239 sys.exit(1)
240
241
242=== modified file 'data/templates/ubuntu-application/submitubuntu.py'
243--- data/templates/ubuntu-application/submitubuntu.py 2010-11-11 14:19:38 +0000
244+++ data/templates/ubuntu-application/submitubuntu.py 2010-12-23 18:15:10 +0000
245@@ -21,15 +21,14 @@
246 import subprocess
247 import webbrowser
248
249-from internal import quicklyutils, packaging, launchpad_helper
250-from internal import bzrutils
251+from internal import quicklyutils
252 from quickly import templatetools, configurationhandler, commands
253+from quickly.ubuntu import packaging
254+import quickly.lp as lp
255 import license
256
257 import logging
258
259-from quickly import launchpadaccess
260-
261 import gettext
262 from gettext import gettext as _
263 gettext.textdomain('quickly')
264@@ -114,8 +113,8 @@
265
266 # connect to LP
267 try:
268- launchpad = launchpadaccess.initialize_lpi()
269-except launchpadaccess.launchpad_connection_error, e:
270+ launchpad = lp.access.initialize_lpi()
271+except lp.access.launchpad_connection_error, e:
272 print(e)
273 sys.exit(1)
274
275@@ -128,11 +127,11 @@
276
277 # get the project now and save the url into setup.py
278 try:
279- project = launchpadaccess.get_project(launchpad)
280-except launchpadaccess.launchpad_project_error, e:
281+ project = lp.project.get_project(launchpad)
282+except lp.access.launchpad_project_error, e:
283 print(e)
284 sys.exit(1)
285-project_url = launchpadaccess.launchpad_url + '/' + project.name
286+project_url = lp.access.launchpad_url + '/' + project.name
287 quicklyutils.set_setup_value('url', project_url)
288 about_dialog_file_name = quicklyutils.get_about_file_name()
289 if about_dialog_file_name:
290@@ -235,14 +234,14 @@
291 sys.exit(1)
292
293
294-if (launchpadaccess.lp_server == "staging"):
295+if (lp.access.lp_server == "staging"):
296 bzr_staging = "//staging/"
297 else:
298 bzr_staging = ""
299
300 custom_location_in_info = None
301 branch_location = []
302-custom_location = bzrutils.get_bzrbranch()
303+custom_location = lp.bzr.get_bzrbranch()
304 if custom_location:
305 branch_location = [custom_location]
306 custom_location_in_info = custom_location.replace('lp:', '')
307@@ -283,15 +282,15 @@
308 sys.exit(return_code)
309
310 #create new release_date
311-launchpad_helper.push_tarball_to_launchpad(project, release_version,
312- "../%s_%s.tar.gz" % (project_name,
313- release_version), changelog)
314+lp.project.push_tarball_to_launchpad(project, release_version,
315+ "../%s_%s.tar.gz" % (project_name,
316+ release_version), changelog)
317
318 print _("%s %s released and submitted to ubuntu. Wait for half an hour and have look at %s.") % (project_name, release_version, ppa_url)
319 print _("Then your application will be reviewed by the application review board.")
320
321 # as launchpad-open doesn't support staging server, put an url
322-if launchpadaccess.lp_server == "staging":
323- webbrowser.open(launchpadaccess.LAUNCHPAD_CODE_STAGING_URL + '/' + project.name)
324+if lp.access.lp_server == "staging":
325+ webbrowser.open(lp.access.LAUNCHPAD_CODE_STAGING_URL + '/' + project.name)
326 else:
327- webbrowser.open(launchpadaccess.LAUNCHPAD_URL + '/' + project.name)
328+ webbrowser.open(lp.access.LAUNCHPAD_URL + '/' + project.name)
329
330=== modified file 'data/templates/ubuntu-application/test/apportutils.py'
331--- data/templates/ubuntu-application/test/apportutils.py 2010-12-20 15:44:44 +0000
332+++ data/templates/ubuntu-application/test/apportutils.py 2010-12-23 18:15:10 +0000
333@@ -14,9 +14,9 @@
334 sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__),"..")))
335 sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__),"..","..","..","..")))
336
337-from internal import apportutils
338+from quickly.ubuntu import apport
339
340-class TestApportUtils(unittest.TestCase):
341+class TestApport(unittest.TestCase):
342 def test_lpi_existing(self):
343 lines = """#!/usr/bin/python
344 import sys
345@@ -56,7 +56,7 @@
346 response = about.run()
347 about.destroy()
348 """.splitlines()
349- self.failIf(apportutils.detect_or_insert_lpi(lines, "project_name1", "helpMenu1"))
350+ self.failIf(apport.detect_or_insert_lpi(lines, "project_name1", "helpMenu1"))
351
352 def test_partial_lpi_import_only(self):
353 lines = """#!/usr/bin/python
354@@ -91,7 +91,7 @@
355 response = about.run()
356 about.destroy()
357 """.splitlines()
358- self.failIf(apportutils.detect_or_insert_lpi(lines, "project_name1", "helpMenu1"))
359+ self.failIf(apport.detect_or_insert_lpi(lines, "project_name1", "helpMenu1"))
360
361 def test_no_lpi(self):
362 lines = """#!/usr/bin/python
363@@ -153,9 +153,9 @@
364 response = about.run()
365 about.destroy()
366 """
367- # print "".join(apportutils.detect_or_insert_lpi(lines, "project_name1", "helpMenu1"))
368+ # print "".join(apport.detect_or_insert_lpi(lines, "project_name1", "helpMenu1"))
369 # print "".join(expected.splitlines(True))
370- self.assertEqual("".join(expected.splitlines(True)).strip(), "".join(apportutils.detect_or_insert_lpi(lines, "project_name1", "helpMenu1")).strip())
371+ self.assertEqual("".join(expected.splitlines(True)).strip(), "".join(apport.detect_or_insert_lpi(lines, "project_name1", "helpMenu1")).strip())
372
373 def test_find_about_menu(self):
374 xml_tree = etree.parse(StringIO.StringIO("""<?xml version="1.0"?>
375@@ -207,6 +207,6 @@
376 </child>
377 </object>
378 </interface>"""))
379- self.assertEqual("testHelpMenu", apportutils.find_about_menu(xml_tree))
380+ self.assertEqual("testHelpMenu", apport.find_about_menu(xml_tree))
381
382 unittest.main()
383
384=== modified file 'data/templates/ubuntu-application/upgrade.py'
385--- data/templates/ubuntu-application/upgrade.py 2010-12-07 14:14:08 +0000
386+++ data/templates/ubuntu-application/upgrade.py 2010-12-23 18:15:10 +0000
387@@ -21,10 +21,9 @@
388 import subprocess
389 import sys
390
391-import internal.apportutils
392-
393 from internal import quicklyutils
394 from quickly import configurationhandler, templatetools
395+from quickly.ubuntu import apport
396
397 import gettext
398 from gettext import gettext as _
399@@ -141,10 +140,10 @@
400 pass
401
402 # add apport hooks if launchpad application is configured
403- internal.apportutils.insert_lpi_if_required(project_name)
404+ apport.insert_lpi_if_required(project_name)
405 lp_project_name = configurationhandler.project_config.get('lp_id', None)
406 if lp_project_name is not None:
407- internal.apportutils.update_apport(project_name, lp_project_name, lp_project_name)
408+ apport.update_apport(project_name, lp_project_name, lp_project_name)
409
410 # new dialog file needs helpers.py
411 if not os.path.isfile('%s/helpers.py' % python_name):
412
413=== added directory 'quickly/lp'
414=== added file 'quickly/lp/__init__.py'
415--- quickly/lp/__init__.py 1970-01-01 00:00:00 +0000
416+++ quickly/lp/__init__.py 2010-12-23 18:15:10 +0000
417@@ -0,0 +1,18 @@
418+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
419+# Copyright 2010 Canonical Ltd
420+#
421+# This file is part of Quickly
422+#
423+#This program is free software: you can redistribute it and/or modify it
424+#under the terms of the GNU General Public License version 3, as published
425+#by the Free Software Foundation.
426+#
427+#This program is distributed in the hope that it will be useful, but
428+#WITHOUT ANY WARRANTY; without even the implied warranties of
429+#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
430+#PURPOSE. See the GNU General Public License for more details.
431+#
432+#You should have received a copy of the GNU General Public License along
433+#with this program. If not, see <http://www.gnu.org/licenses/>.
434+
435+import access, bzr, project
436
437=== renamed file 'quickly/launchpadaccess.py' => 'quickly/lp/access.py'
438--- quickly/launchpadaccess.py 2010-10-13 19:07:55 +0000
439+++ quickly/lp/access.py 2010-12-23 18:15:10 +0000
440@@ -24,7 +24,7 @@
441 LAUNCHPAD_STAGING_URL = "https://staging.launchpad.net"
442 LAUNCHPAD_CODE_STAGING_URL = "https://code.staging.launchpad.net"
443
444-# TODO: see how to export this error on import launchpadaccess (in init.py ?)
445+# TODO: see how to export this error on import quickly.lp.access (in init.py ?)
446 class launchpad_connection_error(Exception):
447 pass
448 class launchpad_project_error(Exception):
449@@ -40,7 +40,7 @@
450 sys.exit(1)
451
452
453-from quickly import bzrbinding
454+from quickly.lp import bzr
455 from quickly import configurationhandler
456
457 import gettext
458@@ -118,7 +118,7 @@
459
460 # try to setup bzr
461 me = launchpad.me
462- (return_code, suggestion) = bzrbinding.bzr_set_login(me.display_name, me.preferred_email_address.email, me.name)
463+ (return_code, suggestion) = bzr.bzr_set_login(me.display_name, me.preferred_email_address.email, me.name)
464
465 if interactive:
466 if launchpad is None or return_code != 0:
467@@ -130,84 +130,3 @@
468
469 return launchpad
470
471-
472-def link_project(launchpad, question, lp_project_name=None):
473- ''' Link to launchpad project, erasing previous one if already set
474-
475-
476- :return project object'''
477-
478- # if config not already loaded
479- if not configurationhandler.project_config:
480- configurationhandler.loadConfig()
481-
482- if not lp_project_name:
483- choice = "0"
484- while choice == "0":
485-
486- lp_id = raw_input("%s, leave blank to abort.\nLaunchpad project name: " % question)
487- if lp_id == "":
488- raise launchpad_project_error(_("No launchpad project given, aborting."))
489-
490- prospective_projects = launchpad.projects.search(text=lp_id)
491- project_number = 1
492- project_names = []
493- for project in prospective_projects:
494- print (_('''---------------- [%s] ----------------
495- %s
496---------------------------------------
497-Project name: %s
498-Launchpad url: %s/%s
499-%s
500-''') % (project_number, project.title, project.display_name, launchpad_url, project.name, project.summary))
501- project_names.append(project.name)
502- project_number += 1
503-
504- if not list(prospective_projects):
505- message = _("No project found")
506- else:
507- message = _("Choose your project number")
508- choice = raw_input("%s, leave blank to abort, 0 for another search.\nYour choice: " % message)
509-
510- try:
511- choice = int(choice)
512- if choice in range(1, project_number):
513- project = launchpad.projects[project_names[choice - 1]]
514- else:
515- raise ValueError
516- except ValueError:
517- raise launchpad_project_error(_("No right number given, aborting."))
518-
519- # we got a project name, check that it exists
520- else:
521- try:
522- project = launchpad.projects[lp_project_name]
523- except KeyError:
524- raise launchpad_project_error(_("Can't find %s project on Launchpad. You can try to find it interactively without providing a project name.") % lp_project_name)
525-
526- configurationhandler.project_config['lp_id'] = project.name
527- configurationhandler.saveConfig()
528-
529- return project
530-
531-def get_project(launchpad):
532- ''' Get quickly project through launchpad.
533-
534- :return project object
535- '''
536-
537- # if config not already loaded
538- if not configurationhandler.project_config:
539- configurationhandler.loadConfig()
540-
541- # try to get project
542- try:
543- lp_id = configurationhandler.project_config['lp_id']
544- project = launchpad.projects[lp_id]
545-
546- # else, bind the project to LP
547- except KeyError:
548- project = link_project(launchpad, "No Launchpad project set")
549-
550- return project
551-
552
553=== renamed file 'quickly/bzrbinding.py' => 'quickly/lp/bzr.py'
554--- quickly/bzrbinding.py 2010-09-28 12:53:04 +0000
555+++ quickly/lp/bzr.py 2010-12-23 18:15:10 +0000
556@@ -1,5 +1,5 @@
557 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
558-# Copyright 2009 Didier Roche
559+# Copyright 2009,2010 Didier Roche
560 #
561 # This file is part of Quickly
562 #
563@@ -17,6 +17,7 @@
564
565 import socket
566 import subprocess
567+from quickly import configurationhandler
568
569 def bzr_set_login(display_name, preferred_email_adress, launchpad_name=None):
570 ''' try to setup bzr whoami for commit and sshing and bzr launchpad_login if provided
571@@ -52,3 +53,21 @@
572
573 return (0, "")
574
575+def set_bzrbranch(bzr_branch):
576+ '''set default bzr branch from where to pull and push'''
577+
578+ if not configurationhandler.project_config:
579+ configurationhandler.loadConfig()
580+ configurationhandler.project_config['bzrbranch'] = bzr_branch
581+
582+def get_bzrbranch():
583+ '''get default bzr branch from where to pull and push'''
584+
585+ if not configurationhandler.project_config:
586+ configurationhandler.loadConfig()
587+
588+ try:
589+ bzr_branch = configurationhandler.project_config['bzrbranch']
590+ except KeyError:
591+ bzr_branch = None
592+ return bzr_branch
593
594=== renamed file 'data/templates/ubuntu-application/internal/launchpad_helper.py' => 'quickly/lp/project.py'
595--- data/templates/ubuntu-application/internal/launchpad_helper.py 2010-08-13 15:04:05 +0000
596+++ quickly/lp/project.py 2010-12-23 18:15:10 +0000
597@@ -22,10 +22,92 @@
598 import sys
599 import subprocess
600
601+from quickly import configurationhandler
602+
603 import gettext
604 from gettext import gettext as _
605 gettext.textdomain('quickly')
606
607+def link_project(launchpad, question, lp_project_name=None):
608+ ''' Link to launchpad project, erasing previous one if already set
609+
610+
611+ :return project object'''
612+
613+ # if config not already loaded
614+ if not configurationhandler.project_config:
615+ configurationhandler.loadConfig()
616+
617+ if not lp_project_name:
618+ choice = "0"
619+ while choice == "0":
620+
621+ lp_id = raw_input("%s, leave blank to abort.\nLaunchpad project name: " % question)
622+ if lp_id == "":
623+ raise launchpad_project_error(_("No launchpad project given, aborting."))
624+
625+ prospective_projects = launchpad.projects.search(text=lp_id)
626+ project_number = 1
627+ project_names = []
628+ for project in prospective_projects:
629+ print (_('''---------------- [%s] ----------------
630+ %s
631+--------------------------------------
632+Project name: %s
633+Launchpad url: %s/%s
634+%s
635+''') % (project_number, project.title, project.display_name, launchpad_url, project.name, project.summary))
636+ project_names.append(project.name)
637+ project_number += 1
638+
639+ if not list(prospective_projects):
640+ message = _("No project found")
641+ else:
642+ message = _("Choose your project number")
643+ choice = raw_input("%s, leave blank to abort, 0 for another search.\nYour choice: " % message)
644+
645+ try:
646+ choice = int(choice)
647+ if choice in range(1, project_number):
648+ project = launchpad.projects[project_names[choice - 1]]
649+ else:
650+ raise ValueError
651+ except ValueError:
652+ raise launchpad_project_error(_("No right number given, aborting."))
653+
654+ # we got a project name, check that it exists
655+ else:
656+ try:
657+ project = launchpad.projects[lp_project_name]
658+ except KeyError:
659+ raise launchpad_project_error(_("Can't find %s project on Launchpad. You can try to find it interactively without providing a project name.") % lp_project_name)
660+
661+ configurationhandler.project_config['lp_id'] = project.name
662+ configurationhandler.saveConfig()
663+
664+ return project
665+
666+def get_project(launchpad):
667+ ''' Get quickly project through launchpad.
668+
669+ :return project object
670+ '''
671+
672+ # if config not already loaded
673+ if not configurationhandler.project_config:
674+ configurationhandler.loadConfig()
675+
676+ # try to get project
677+ try:
678+ lp_id = configurationhandler.project_config['lp_id']
679+ project = launchpad.projects[lp_id]
680+
681+ # else, bind the project to LP
682+ except KeyError:
683+ project = link_project(launchpad, "No Launchpad project set")
684+
685+ return project
686+
687 #TODO: see if 0 release in the project
688
689 def create_release(project, version):
690
691=== added directory 'quickly/ubuntu'
692=== added file 'quickly/ubuntu/__init__.py'
693--- quickly/ubuntu/__init__.py 1970-01-01 00:00:00 +0000
694+++ quickly/ubuntu/__init__.py 2010-12-23 18:15:10 +0000
695@@ -0,0 +1,18 @@
696+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
697+# Copyright 2010 Canonical Ltd
698+#
699+# This file is part of Quickly
700+#
701+#This program is free software: you can redistribute it and/or modify it
702+#under the terms of the GNU General Public License version 3, as published
703+#by the Free Software Foundation.
704+#
705+#This program is distributed in the hope that it will be useful, but
706+#WITHOUT ANY WARRANTY; without even the implied warranties of
707+#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
708+#PURPOSE. See the GNU General Public License for more details.
709+#
710+#You should have received a copy of the GNU General Public License along
711+#with this program. If not, see <http://www.gnu.org/licenses/>.
712+
713+import apport, packaging
714
715=== renamed file 'data/templates/ubuntu-application/internal/apportutils.py' => 'quickly/ubuntu/apport.py'
716=== renamed file 'data/templates/ubuntu-application/internal/packaging.py' => 'quickly/ubuntu/packaging.py'
717--- data/templates/ubuntu-application/internal/packaging.py 2010-11-23 14:26:08 +0000
718+++ quickly/ubuntu/packaging.py 2010-12-23 18:15:10 +0000
719@@ -24,7 +24,7 @@
720
721
722 from quickly import configurationhandler
723-from quickly import launchpadaccess
724+import quickly.lp as lp
725 from internal import quicklyutils
726 from quickly import templatetools
727
728@@ -229,8 +229,8 @@
729
730 # connect to LP and get ppa to complete
731 try:
732- launchpad = launchpadaccess.initialize_lpi(False)
733- except launchpadaccess.launchpad_connection_error:
734+ launchpad = lp.access.initialize_lpi(False)
735+ except lp.access.launchpad_connection_error:
736 sys.exit(0)
737 available_ppas = []
738 if launchpad:
739@@ -287,13 +287,13 @@
740 (ppa_user, ppa_name) = get_ppa_parameters(launchpad, configurationhandler.project_config['ppa'])
741 except KeyError:
742 ppa_user = launchpad.me
743- if (launchpadaccess.lp_server == "staging"):
744+ if (lp.access.lp_server == "staging"):
745 ppa_name = 'staging'
746 else: # default ppa
747 ppa_name = 'ppa'
748 else:
749 (ppa_user, ppa_name) = get_ppa_parameters(launchpad, ppa_name)
750- ppa_url = '%s/~%s/+archive/%s' % (launchpadaccess.LAUNCHPAD_URL, ppa_user.name, ppa_name)
751+ ppa_url = '%s/~%s/+archive/%s' % (lp.access.LAUNCHPAD_URL, ppa_user.name, ppa_name)
752 dput_ppa_name = 'ppa:%s/%s' % (ppa_user.name, ppa_name)
753 return (ppa_user, ppa_name, dput_ppa_name, ppa_url.encode('UTF-8'))
754

Subscribers

People subscribed via source and target branches