Merge lp:~barry/apturl/py3 into lp:apturl

Proposed by Barry Warsaw
Status: Merged
Merged at revision: 126
Proposed branch: lp:~barry/apturl/py3
Merge into: lp:apturl
Diff against target: 1084 lines (+219/-210)
21 files modified
AptUrl/AptUrl.py (+31/-30)
AptUrl/Helpers.py (+18/-8)
AptUrl/Parser.py (+2/-2)
AptUrl/UI.py (+0/-1)
AptUrl/gtk/GtkUI.py (+23/-16)
AptUrl/gtk/backend/__init__.py (+2/-2)
AptUrl/kde/KdeUI.py (+27/-41)
apturl-gtk (+2/-3)
apturl-kde (+7/-8)
debian/apturl-common.install (+2/-2)
debian/apturl-kde.install (+1/-1)
debian/apturl.install (+2/-2)
debian/changelog (+21/-0)
debian/compat (+1/-1)
debian/control (+16/-15)
debian/pycompat (+0/-1)
debian/rules (+7/-4)
po/apturl.pot (+40/-41)
setup.py (+5/-5)
tests/test_apturl_parse.py (+9/-17)
tests/test_helpers.py (+3/-10)
To merge this branch: bzr merge lp:~barry/apturl/py3
Reviewer Review Type Date Requested Status
Stéphane Graber Approve
Michael Vogt Pending
Review via email: mp+109949@code.launchpad.net

Description of the change

A working port to Python 3.

To post a comment you must log in.
Revision history for this message
Stéphane Graber (stgraber) wrote :

Things that I can't easily check just through the proposal:
 - Does the package actually build? The concern here being the use of "python3 ./setup.py install --install-layout=deb"
 - "#desc = "%s\n\n%s" % (summary, Helpers.format_description(description))" in KDEui.py, why was that line commented rather than removed if "desc" isn't used?

Besides that, the rest looks good, so with an answer to these two, +1

review: Approve
Revision history for this message
Barry Warsaw (barry) wrote :

On Jun 12, 2012, at 10:42 PM, Stéphane Graber wrote:

>Things that I can't easily check just through the proposal:

> - Does the package actually build? The concern here being the use of "python3 ./setup.py install --install-layout=deb"

I'm testing this now, but it requires unreleased versions of update-manager
and aptdaemon, so it's a bit tricky. :) I certainly won't upload it until
both those are released and the apturl build is tested.

> - "#desc = "%s\n\n%s" % (summary, Helpers.format_description(description))" in KDEui.py, why was that line commented rather than removed if "desc" isn't used?

You can't tell from the diff, but there's other code commented out below that
references it. I suppose I should just remove all the commented out code
instead.

>Besides that, the rest looks good, so with an answer to these two, +1

Thanks!

lp:~barry/apturl/py3 updated
133. By Barry Warsaw

+ Port setup.py to Python 3.
+ Fix python3-update-manager dependencies.
+ override_dh_auto_build to build with Python 3.
+ python3 setup.py install needs --root

Revision history for this message
Barry Warsaw (barry) wrote :

With the new uploads of update-manager and aptdaemon, this should be ready to go.

lp:~barry/apturl/py3 updated
134. By Barry Warsaw

apturl now must require python3-aptdaemon.gtk3widgets (i.e. not |
synaptic) due to the Python 3 port of update-manager.

Revision history for this message
Barry Warsaw (barry) wrote :

<xnox> then why Except: #Python 3 [20:44]
<xnox> 204 - homepage = pkgobj.homepage
<xnox> 205 + try:
<xnox> 206 + homepage = pkgobj.homepage
<xnox> 207 + except AttributeError:
<xnox> 208 + # Python 3
<xnox> 209 + homepage = pkgobj.versions[0].homepage

<xnox> then I would expect universal_newlines=True in the Popen as well, if
       you were playing it safe ;-) [20:45]
<xnox> +from __future__ import print_function
<xnox> 460 - desc = "%s\n\n%s" % (summary,
       Helpers.format_description(description)) [20:46]
<xnox> 461 + #desc = "%s\n\n%s" % (summary,
       Helpers.format_description(description))
<xnox> intentional comment out?
<xnox> are we meant to install 597
       +usr/lib/python3/*-packages/apturl-*.egg-info ? [20:47]

<xnox> ok.
<xnox> barry: debian/compat == 8
<xnox> use 9
<xnox> 8 was really a temp thing.
<xnox> and precise has 9 [20:48]

Revision history for this message
Barry Warsaw (barry) wrote :

<cjwatson> barry: The new apt API exists for py2 as well, and it's important
           to port to it because the old one is slated to go away
<cjwatson> (given that the new one has been around since lucid)
<barry> cjwatson: agreed. i'll get rid of the old api
<barry> (or mostly the try/excepts around the old api calls) [20:52]
<cjwatson> (Also, pkgobj.candidate.homepage maybe?)

<cjwatson> + verStr = self.cache[apturl.package].candidate_version [20:53]
<cjwatson> that looks wrong, .candidate.version perhaps

Revision history for this message
Barry Warsaw (barry) wrote :

<cjwatson> + # be locked via apt_pkg.GetLock()
<cjwatson> whitespace change only here in a comment, but maybe update the
           comment to .get_lock()

lp:~barry/apturl/py3 updated
135. By Barry Warsaw

Change debian/compat == 9

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'AptUrl/AptUrl.py'
--- AptUrl/AptUrl.py 2012-06-11 20:34:59 +0000
+++ AptUrl/AptUrl.py 2012-06-14 00:37:19 +0000
@@ -20,17 +20,15 @@
20# along with AptUrl; if not, write to the Free Software20# along with AptUrl; if not, write to the Free Software
21# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA21# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2222
23import sys
24import apt23import apt
25import apt_pkg24import apt_pkg
26import gettext
2725
28import aptsources.distro26import aptsources.distro
29from . import Parser27from . import Parser
30from . import Helpers28from . import Helpers
31from .Helpers import _29from .Helpers import _
3230
33from aptsources.sourceslist import SourcesList, is_mirror31from aptsources.sourceslist import SourcesList
34from optparse import OptionParser32from optparse import OptionParser
3533
36import os34import os
@@ -55,8 +53,6 @@
55 self.ui = ui53 self.ui = ui
5654
57 def enableSection(self, apturl):55 def enableSection(self, apturl):
58 added = False
59
60 # parse sources.list56 # parse sources.list
61 sourceslist = SourcesList()57 sourceslist = SourcesList()
62 distro = aptsources.distro.get_distro()58 distro = aptsources.distro.get_distro()
@@ -74,7 +70,8 @@
74 if not self.ui.askEnableSections(apturl.section):70 if not self.ui.askEnableSections(apturl.section):
75 return RESULT_CANCELT71 return RESULT_CANCELT
76 if not self.ui.doEnableSection(apturl.section):72 if not self.ui.doEnableSection(apturl.section):
77 self.ui.error(_("Enabling '%s' failed") % ", ".join(apturl.section))73 self.ui.error(_("Enabling '%s' failed") %
74 ", ".join(apturl.section))
78 return RESULT_ERROR75 return RESULT_ERROR
79 self.ui.doUpdate()76 self.ui.doUpdate()
80 self.openCache()77 self.openCache()
@@ -114,9 +111,9 @@
114 raise111 raise
115 self.ui.error(_("Invalid /etc/apt/sources.list file"), strerr)112 self.ui.error(_("Invalid /etc/apt/sources.list file"), strerr)
116 return False113 return False
117 if self.cache._depcache.BrokenCount > 0:114 if self.cache._depcache.broken_count > 0:
118 err_header = _("Software index is broken")115 err_header = _("Software index is broken")
119 err_body = _("This is a major failure of your software " 116 err_body = _("This is a major failure of your software "
120 "management system. Please check for broken packages "117 "management system. Please check for broken packages "
121 "with synaptic, check the file permissions and "118 "with synaptic, check the file permissions and "
122 "correctness of the file '/etc/apt/sources.list' and "119 "correctness of the file '/etc/apt/sources.list' and "
@@ -126,7 +123,7 @@
126 self.ui.error(err_header, err_body)123 self.ui.error(err_header, err_body)
127 return False124 return False
128 return True125 return True
129 126
130 def parseArgs(self):127 def parseArgs(self):
131 parser = OptionParser()128 parser = OptionParser()
132 parser.add_option("-p", "--http-proxy", dest="http_proxy",129 parser.add_option("-p", "--http-proxy", dest="http_proxy",
@@ -151,15 +148,15 @@
151 str(e))148 str(e))
152 return []149 return []
153 return (apturl_list)150 return (apturl_list)
154 151
155 def verifyInstall(self, apturl):152 def verifyInstall(self, apturl):
156 " verify that the install package actually is installed "153 " verify that the install package actually is installed "
157 # check if the package got actually installed154 # check if the package got actually installed
158 self.openCache()155 self.openCache()
159 pkg = self.cache[apturl.package]156 pkg = self.cache[apturl.package]
160 if (not pkg.isInstalled or157 if (not pkg.is_installed or
161 pkg._pkg.CurrentState != apt_pkg.CurStateInstalled or158 pkg._pkg.current_state != apt_pkg.CURSTATE_INSTALLED or
162 self.cache._depcache.BrokenCount > 0):159 self.cache._depcache.broken_count > 0):
163 return False160 return False
164 return True161 return True
165162
@@ -167,12 +164,12 @@
167 # global return code164 # global return code
168 ret = RESULT_OK165 ret = RESULT_OK
169 ui = self.ui166 ui = self.ui
170 167
171 # parse arguments168 # parse arguments
172 apturl_list = self.parseArgs()169 apturl_list = self.parseArgs()
173 if not apturl_list:170 if not apturl_list:
174 return RESULT_BADARGS171 return RESULT_BADARGS
175 172
176 # open cache173 # open cache
177 if not self.openCache():174 if not self.openCache():
178 return RESULT_ERROR175 return RESULT_ERROR
@@ -183,7 +180,8 @@
183 # evalAptUrl()180 # evalAptUrl()
184181
185 if not apturl.schema in ("apt", "apt+http"):182 if not apturl.schema in ("apt", "apt+http"):
186 self.ui.error(_("Can not deal with protocol '%s' ") % apturl.schema)183 self.ui.error(_("Can not deal with protocol '%s' ")
184 % apturl.schema)
187 continue185 continue
188186
189 if apturl.section:187 if apturl.section:
@@ -196,7 +194,7 @@
196 ui.doUpdate()194 ui.doUpdate()
197 if not self.openCache():195 if not self.openCache():
198 return RESULT_ERROR196 return RESULT_ERROR
199 197
200 # now check the package198 # now check the package
201 if apturl.package not in self.cache:199 if apturl.package not in self.cache:
202 try:200 try:
@@ -207,11 +205,14 @@
207 ui.error(_("Package '%s' is virtual.") % apturl.package)205 ui.error(_("Package '%s' is virtual.") % apturl.package)
208 continue206 continue
209 else:207 else:
210 ui.error(_("Could not find package '%s'.") % apturl.package)208 ui.error(_("Could not find package '%s'.")
209 % apturl.package)
211 continue210 continue
212 211
213 if self.cache[apturl.package].isInstalled and apturl.minver is None:212 if (self.cache[apturl.package].is_installed and
214 ui.message(_("Package '%s' is already installed") % apturl.package)213 apturl.minver is None):
214 ui.message(_("Package '%s' is already installed")
215 % apturl.package)
215 continue216 continue
216217
217 # ask the user218 # ask the user
@@ -220,20 +221,21 @@
220 if not ui.askInstallPackage(apturl.package, sum, desc, homepage):221 if not ui.askInstallPackage(apturl.package, sum, desc, homepage):
221 ret = RESULT_CANCELT222 ret = RESULT_CANCELT
222 continue223 continue
223 224
224 # try to install it225 # try to install it
225 try:226 try:
226 self.cache[apturl.package].markInstall()227 self.cache[apturl.package].mark_install()
227 except SystemError as e:228 except SystemError as e:
228 ui.error(_("Can not install '%s' (%s) ") % (apturl.package, e))229 ui.error(_("Can not install '%s' (%s) ") % (apturl.package, e))
229 continue230 continue
230 if apturl.minver is not None:231 if apturl.minver is not None:
231 verStr = self.cache[apturl.package].candidateVersion232 verStr = self.cache[apturl.package].candidate_version
232 if apt_pkg.VersionCompare(verStr, apturl.minver) < 1:233 if apt_pkg.version_compare(verStr, apturl.minver) < 1:
233 ui.error(_("Package '%s' requests minimal version '%s', but "234 ui.error(_(
234 "only '%s' is available") % (apturl.package,235 "Package '%s' requests minimal version '%s', but "
235 apturl.minver,236 "only '%s' is available") % (apturl.package,
236 verStr))237 apturl.minver,
238 verStr))
237 continue239 continue
238240
239 # install it241 # install it
@@ -244,4 +246,3 @@
244246
245 # return values247 # return values
246 return ret248 return ret
247
248249
=== modified file 'AptUrl/Helpers.py'
--- AptUrl/Helpers.py 2012-06-11 21:35:40 +0000
+++ AptUrl/Helpers.py 2012-06-14 00:37:19 +0000
@@ -39,25 +39,35 @@
39 return str39 return str
4040
41def get_dist():41def get_dist():
42 return subprocess.Popen(["lsb_release","-c","-s"],stdout=subprocess.PIPE).communicate()[0].strip()42 return subprocess.Popen(["lsb_release","-c","-s"],
43 stdout=subprocess.PIPE).communicate()[0].strip()
4344
4445
45def parse_pkg(pkgobj):46def parse_pkg(pkgobj):
46 summary = ""47 summary = ""
47 description = ""48 description = ""
48 if pkgobj.description.count("\n") > 0:49 try:
49 summary, description = pkgobj.description.split('\n', 1)50 pkg_description = pkgobj.description
51 except AttributeError:
52 # Python 3
53 pkg_description = pkgobj.versions[0].description
54 if pkg_description.count("\n") > 0:
55 summary, description = pkg_description.split('\n', 1)
50 else:56 else:
51 summary = pkgobj.description57 summary = pkg_description
52 lines = description.rstrip('\n').split('\n')58 lines = description.rstrip('\n').split('\n')
53 if len(lines) > 1 and lines[-1].startswith('Homepage: '):59 if len(lines) > 1 and lines[-1].startswith('Homepage: '):
54 homepage = lines[-1].split(' ', 1)[1]60 homepage = lines[-1].split(' ', 1)[1]
55 description = '\n'.join(lines[:-1])61 description = '\n'.join(lines[:-1])
56 else:62 else:
57 homepage = pkgobj.homepage63 try:
64 homepage = pkgobj.homepage
65 except AttributeError:
66 # Python 3
67 homepage = pkgobj.versions[0].homepage
58 return (summary, description, homepage)68 return (summary, description, homepage)
5969
60def format_description(description):70def format_description(description):
61 const = 'APTURL_DOUBLE_EMPTY_LINE_PLACEHOLDER'71 const = 'APTURL_DOUBLE_EMPTY_LINE_PLACEHOLDER'
62 return description.replace('\n\n', const).replace('\n', ' ').replace(72 return description.replace('\n\n', const).replace('\n', ' ').replace(
63 const, '\n\n')73 const, '\n\n')
6474
=== modified file 'AptUrl/Parser.py'
--- AptUrl/Parser.py 2012-06-11 21:35:40 +0000
+++ AptUrl/Parser.py 2012-06-14 00:37:19 +0000
@@ -23,7 +23,6 @@
23import os23import os
24import string24import string
25from string import Template25from string import Template
26from subprocess import Popen, PIPE
27from .Helpers import get_dist26from .Helpers import get_dist
28from .Helpers import _27from .Helpers import _
2928
@@ -82,7 +81,8 @@
82 " test if the url matches the internal whitelist "81 " test if the url matches the internal whitelist "
83 for char in raw_url:82 for char in raw_url:
84 if not char in whitelist:83 if not char in whitelist:
85 raise InvalidUrlException(raw_url, _("Non whitelist char in the uri"))84 raise InvalidUrlException(
85 raw_url, _("Non whitelist char in the uri"))
86 return True86 return True
8787
88def set_value(apt_url, s):88def set_value(apt_url, s):
8989
=== modified file 'AptUrl/UI.py'
--- AptUrl/UI.py 2012-06-11 20:34:59 +0000
+++ AptUrl/UI.py 2012-06-14 00:37:19 +0000
@@ -1,5 +1,4 @@
11
2from . import Helpers
3from .Helpers import _, _n2from .Helpers import _, _n
43
5class AbstractUI(object):4class AbstractUI(object):
65
=== modified file 'AptUrl/gtk/GtkUI.py'
--- AptUrl/gtk/GtkUI.py 2012-06-11 20:34:59 +0000
+++ AptUrl/gtk/GtkUI.py 2012-06-14 00:37:19 +0000
@@ -5,14 +5,11 @@
5from gi.repository import Gdk5from gi.repository import Gdk
6from gi.repository import GObject6from gi.repository import GObject
7GObject.threads_init()7GObject.threads_init()
8import subprocess8
9import os
9import sys10import sys
10
11import os
12import os.path
13
14import apt_pkg11import apt_pkg
1512import subprocess
1613
17from AptUrl.UI import AbstractUI14from AptUrl.UI import AbstractUI
18from AptUrl import Helpers15from AptUrl import Helpers
@@ -20,13 +17,22 @@
2017
21from .backend import get_backend18from .backend import get_backend
2219
20
21APTURL_UI_FILE = os.environ.get(
22 # Set this envar to use a test .ui file.
23 'APTURL_UI_FILE',
24 # System file to use if the envar is not set.
25 '/usr/share/apturl/apturl-gtk.ui'
26 )
27
28
23class GtkUI(AbstractUI):29class GtkUI(AbstractUI):
24 def __init__(self):30 def __init__(self):
25 Gtk.init_check(sys.argv)31 Gtk.init_check(sys.argv)
26 # create empty dialog32 # create empty dialog
27 self.dia_xml = Gtk.Builder()33 self.dia_xml = Gtk.Builder()
28 self.dia_xml.set_translation_domain("apturl")34 self.dia_xml.set_translation_domain("apturl")
29 self.dia_xml.add_from_file('/usr/share/apturl/apturl-gtk.ui')35 self.dia_xml.add_from_file(APTURL_UI_FILE)
30 self.dia = self.dia_xml.get_object('confirmation_dialog')36 self.dia = self.dia_xml.get_object('confirmation_dialog')
31 self.dia.realize()37 self.dia.realize()
32 self.backend = get_backend(self.dia)38 self.backend = get_backend(self.dia)
@@ -37,7 +43,8 @@
37 Gtk.main_quit()43 Gtk.main_quit()
3844
39 # generic dialogs45 # generic dialogs
40 def _get_dialog(self, dialog_type, summary, msg="", buttons=Gtk.ButtonsType.CLOSE):46 def _get_dialog(self, dialog_type, summary, msg="",
47 buttons=Gtk.ButtonsType.CLOSE):
41 " internal helper for dialog construction "48 " internal helper for dialog construction "
42 d = Gtk.MessageDialog(parent=self.dia,49 d = Gtk.MessageDialog(parent=self.dia,
43 flags=Gtk.DialogFlags.MODAL,50 flags=Gtk.DialogFlags.MODAL,
@@ -50,7 +57,7 @@
50 d.realize()57 d.realize()
51 d.get_window().set_functions(Gdk.WMFunction.MOVE)58 d.get_window().set_functions(Gdk.WMFunction.MOVE)
52 return d59 return d
53 60
54 def error(self, summary, msg=""):61 def error(self, summary, msg=""):
55 d = self._get_dialog(Gtk.MessageType.ERROR, summary, msg)62 d = self._get_dialog(Gtk.MessageType.ERROR, summary, msg)
56 d.run()63 d.run()
@@ -73,7 +80,7 @@
73 if res != Gtk.ResponseType.YES:80 if res != Gtk.ResponseType.YES:
74 return False81 return False
75 return True82 return True
76 83
77 # specific dialogs84 # specific dialogs
78 def askEnableChannel(self, channel, channel_info_html):85 def askEnableChannel(self, channel, channel_info_html):
79 summary = _("Enable additional software channel")86 summary = _("Enable additional software channel")
@@ -115,7 +122,7 @@
115 return False122 return False
116 return True123 return True
117124
118 125
119 def doEnableChannel(self, channelpath, channelkey):126 def doEnableChannel(self, channelpath, channelkey):
120 cmd = ["gksu",127 cmd = ["gksu",
121 "--desktop", "/usr/share/applications/gnome-app-install.desktop",128 "--desktop", "/usr/share/applications/gnome-app-install.desktop",
@@ -155,25 +162,25 @@
155 tbuf.set_text(desc)162 tbuf.set_text(desc)
156 description_text_view.set_buffer(tbuf)163 description_text_view.set_buffer(tbuf)
157 dia.set_icon(Gtk.IconTheme.get_default().load_icon('deb', 16, False))164 dia.set_icon(Gtk.IconTheme.get_default().load_icon('deb', 16, False))
158 165
159 # check if another package manager is already running166 # check if another package manager is already running
160 # FIXME: just checking for the existance of the file is167 # FIXME: just checking for the existance of the file is
161 # not sufficient, it need to be tested if it can168 # not sufficient, it need to be tested if it can
162 # be locked via apt_pkg.GetLock() 169 # be locked via apt_pkg.GetLock()
163 # - but that needs to run as root 170 # - but that needs to run as root
164 # - a dbus helper might be the best answer here171 # - a dbus helper might be the best answer here
165 #args = (update_button_status, dia_xml.get_object("yes_button"),172 #args = (update_button_status, dia_xml.get_object("yes_button"),
166 # dia_xml.get_object("infolabel"))173 # dia_xml.get_object("infolabel"))
167 #args[0](*args[1:])174 #args[0](*args[1:])
168 #timer_id = GObject.timeout_add(750, *args )175 #timer_id = GObject.timeout_add(750, *args )
169 176
170 # show the dialog177 # show the dialog
171 res = dia.run()178 res = dia.run()
172 #GObject.source_remove(timer_id)179 #GObject.source_remove(timer_id)
173 if res != Gtk.ResponseType.YES:180 if res != Gtk.ResponseType.YES:
174 dia.hide()181 dia.hide()
175 return False182 return False
176 183
177 # don't set on-top while installing184 # don't set on-top while installing
178 dia.set_keep_above(False)185 dia.set_keep_above(False)
179 return True186 return True
180187
=== modified file 'AptUrl/gtk/backend/__init__.py'
--- AptUrl/gtk/backend/__init__.py 2011-07-22 12:04:26 +0000
+++ AptUrl/gtk/backend/__init__.py 2012-06-14 00:37:19 +0000
@@ -45,7 +45,7 @@
45 not "UPDATE_MANAGER_FORCE_BACKEND_SYNAPTIC" in os.environ):45 not "UPDATE_MANAGER_FORCE_BACKEND_SYNAPTIC" in os.environ):
46 # check if the gtkwidgets are installed as well46 # check if the gtkwidgets are installed as well
47 try:47 try:
48 from InstallBackendAptdaemon import InstallBackendAptdaemon48 from .InstallBackendAptdaemon import InstallBackendAptdaemon
49 return InstallBackendAptdaemon(*args, **kwargs)49 return InstallBackendAptdaemon(*args, **kwargs)
50 except ImportError:50 except ImportError:
51 import logging51 import logging
@@ -53,7 +53,7 @@
53 # try synaptic53 # try synaptic
54 if (os.path.exists("/usr/sbin/synaptic") and54 if (os.path.exists("/usr/sbin/synaptic") and
55 not "UPDATE_MANAGER_FORCE_BACKEND_APTDAEMON" in os.environ):55 not "UPDATE_MANAGER_FORCE_BACKEND_APTDAEMON" in os.environ):
56 from InstallBackendSynaptic import InstallBackendSynaptic56 from .InstallBackendSynaptic import InstallBackendSynaptic
57 return InstallBackendSynaptic(*args, **kwargs)57 return InstallBackendSynaptic(*args, **kwargs)
58 # nothing found, raise58 # nothing found, raise
59 raise Exception("No working backend found, please try installing "59 raise Exception("No working backend found, please try installing "
6060
=== modified file 'AptUrl/kde/KdeUI.py'
--- AptUrl/kde/KdeUI.py 2012-06-11 20:34:59 +0000
+++ AptUrl/kde/KdeUI.py 2012-06-14 00:37:19 +0000
@@ -1,6 +1,6 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
22
3from __future__ import print_funcion3from __future__ import print_function
44
5from PyQt4.QtCore import *5from PyQt4.QtCore import *
6from PyQt4.QtGui import *6from PyQt4.QtGui import *
@@ -9,19 +9,20 @@
9from PyKDE4.kdeui import *9from PyKDE4.kdeui import *
10from PyKDE4.kdecore import *10from PyKDE4.kdecore import *
1111
12import subprocess
13from tempfile import NamedTemporaryFile
14
15import os12import os
16import os.path
17
18import time
19import thread
20import apt_pkg13import apt_pkg
14import subprocess
2115
22from AptUrl.UI import AbstractUI16from AptUrl.UI import AbstractUI
23from AptUrl import Helpers17from AptUrl.Helpers import _
24from AptUrl.Helpers import utf8, _, _n18
19APTURL_UI_FILE = os.environ.get(
20 # Set this envar to use a test .ui file.
21 'APTURL_UI_FILE',
22 # System file to use if the envar is not set.
23 '/usr/share/apturl/apturl-qt.ui'
24 )
25
2526
26class AptUrlDialog(KDialog):27class AptUrlDialog(KDialog):
27 def __init__(self,parent=None):28 def __init__(self,parent=None):
@@ -34,6 +35,7 @@
34 else:35 else:
35 KDialog.reject(self)36 KDialog.reject(self)
3637
38
37class KdeUI(AbstractUI):39class KdeUI(AbstractUI):
38 def __init__(self):40 def __init__(self):
39 self.dialog = AptUrlDialog()41 self.dialog = AptUrlDialog()
@@ -41,7 +43,7 @@
41 self.d = QWidget(self.dialog)43 self.d = QWidget(self.dialog)
42 self.dialog.setMainWidget(self.d)44 self.dialog.setMainWidget(self.d)
4345
44 uic.loadUi('/usr/share/apturl/apturl-qt.ui', self.d)46 uic.loadUi(APTURL_UI_FILE, self.d)
45 self.d.image_label.setPixmap(KIcon("application-x-deb").pixmap(64,64))47 self.d.image_label.setPixmap(KIcon("application-x-deb").pixmap(64,64))
4648
47 # generic dialogs49 # generic dialogs
@@ -97,7 +99,8 @@
97 "software-properties-kde",99 "software-properties-kde",
98 "--enable-component", "%s" % ' '.join(sections)]100 "--enable-component", "%s" % ' '.join(sections)]
99 try:101 try:
100 output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]102 output = subprocess.Popen(
103 cmd, stdout=subprocess.PIPE).communicate()[0]
101 except OSError as e:104 except OSError as e:
102 print("Execution failed: %s" % e, file=sys.stderr)105 print("Execution failed: %s" % e, file=sys.stderr)
103 return True106 return True
@@ -129,7 +132,7 @@
129 def askInstallPackage(self, package, summary, description, homepage):132 def askInstallPackage(self, package, summary, description, homepage):
130 header = "<h2>" + _("Install additional software?") + "</h2>"133 header = "<h2>" + _("Install additional software?") + "</h2>"
131 body = _("Do you want to install package '%s'?") % package134 body = _("Do you want to install package '%s'?") % package
132 desc = "%s\n\n%s" % (summary, Helpers.format_description(description))135 #desc = "%s\n\n%s" % (summary, Helpers.format_description(description))
133136
134 self.d.header_label.setText(header)137 self.d.header_label.setText(header)
135 self.d.body_label.setText(body)138 self.d.body_label.setText(body)
@@ -145,36 +148,19 @@
145148
146 # progress etc149 # progress etc
147 def doUpdate(self):150 def doUpdate(self):
148 p = subprocess.Popen(['qapt-batch',151 subprocess.check_call([
149 '--attach', str(self.dialog.winId()),152 'qapt-batch',
150 '--update'153 '--attach', str(self.dialog.winId()),
151 ])154 '--update'
152 self._wait_for_install_package(p)155 ])
153156
154 def doInstall(self, apturl):157 def doInstall(self, apturl):
155 p = subprocess.Popen(['qapt-batch',158 subprocess.check_call([
156 '--attach', str(self.dialog.winId()),159 'qapt-batch',
157 '--install',160 '--attach', str(self.dialog.winId()),
158 apturl.package161 '--install',
159 ])162 apturl.package
160 self._wait_for_install_package(p)163 ])
161 return True
162
163 # helpers
164 def _wait_for_p(self, p, lock):
165 " helper for the thread to wait for process p to finish "
166 p.wait()
167 lock.release()
168
169 def _wait_for_install_package(self, p):
170 # wait for qapt-batch
171 lock = thread.allocate_lock()
172 lock.acquire()
173 thread.start_new_thread(self._wait_for_p, (p, lock))
174
175 while lock.locked():
176 time.sleep(0.01)
177 return True
178164
179165
180if __name__ == "__main__":166if __name__ == "__main__":
181167
=== modified file 'apturl-gtk'
--- apturl-gtk 2012-06-11 20:34:59 +0000
+++ apturl-gtk 2012-06-14 00:37:19 +0000
@@ -1,4 +1,4 @@
1#!/usr/bin/python1#!/usr/bin/python3
2#2#
3# Copyright (c) 2007-2008 Canonical3# Copyright (c) 2007-2008 Canonical
4#4#
@@ -22,13 +22,12 @@
22# along with AptUrl; if not, write to the Free Software22# along with AptUrl; if not, write to the Free Software
23# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA23# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2424
25from __future__ import print_function
2526
26# ignore apt's "API not stable yet" warning27# ignore apt's "API not stable yet" warning
27import warnings28import warnings
28warnings.filterwarnings("ignore", category=FutureWarning, append=1)29warnings.filterwarnings("ignore", category=FutureWarning, append=1)
2930
30from __future__ import print_function
31
32import sys31import sys
33import gettext32import gettext
34from gettext import gettext as _33from gettext import gettext as _
3534
=== modified file 'apturl-kde'
--- apturl-kde 2012-06-11 20:34:59 +0000
+++ apturl-kde 2012-06-14 00:37:19 +0000
@@ -1,4 +1,4 @@
1#!/usr/bin/python1#!/usr/bin/python3
2# -*- coding: utf-8 -*-2# -*- coding: utf-8 -*-
3#3#
4# Copyright © 2009 Harald Sitter <apachelogger@ubuntu.com>4# Copyright © 2009 Harald Sitter <apachelogger@ubuntu.com>
@@ -22,13 +22,12 @@
22# along with AptUrl; if not, write to the Free Software22# along with AptUrl; if not, write to the Free Software
23# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA23# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2424
25from __future__ import print_function
2526
26# ignore apt's "API not stable yet" warning27# ignore apt's "API not stable yet" warning
27import warnings28import warnings
28warnings.filterwarnings("ignore", category=FutureWarning, append=1)29warnings.filterwarnings("ignore", category=FutureWarning, append=1)
2930
30from __future__ import print_function
31
32import sys31import sys
33import gettext32import gettext
34from gettext import gettext as _33from gettext import gettext as _
@@ -58,18 +57,18 @@
58if __name__ == "__main__":57if __name__ == "__main__":
59 appName = "apturl"58 appName = "apturl"
60 catalog = ""59 catalog = ""
61 programName = ki18n ("AptUrl")60 programName = ki18n (b"AptUrl")
62 version = "1.0"61 version = "1.0"
63 description = ki18n ("AptUrl for Kubuntu")62 description = ki18n (b"AptUrl for Kubuntu")
64 license = KAboutData.License_GPL63 license = KAboutData.License_GPL
65 copyright = ki18n ("© Harald Sitter")64 copyright = ki18n ("© Harald Sitter".encode('utf-8'))
66 text = ki18n ("none")65 text = ki18n (b"none")
67 homePage = "http://www.kubuntu.org/"66 homePage = "http://www.kubuntu.org/"
68 bugEmail = ""67 bugEmail = ""
6968
70 about = KAboutData (appName, catalog, programName, version, description,69 about = KAboutData (appName, catalog, programName, version, description,
71 license, copyright, text, homePage, bugEmail)70 license, copyright, text, homePage, bugEmail)
72 about.addAuthor(ki18n("Harald Sitter"), KLocalizedString(),71 about.addAuthor(ki18n(b"Harald Sitter"), KLocalizedString(),
73 "apachelogger@ubuntu.com")72 "apachelogger@ubuntu.com")
74 KCmdLineArgs.init([""],about)73 KCmdLineArgs.init([""],about)
7574
7675
=== modified file 'debian/apturl-common.install'
--- debian/apturl-common.install 2011-03-30 13:46:50 +0000
+++ debian/apturl-common.install 2012-06-14 00:37:19 +0000
@@ -1,7 +1,7 @@
1etc/1etc/
2usr/bin/apturl2usr/bin/apturl
3usr/lib/python2.?/*-packages/AptUrl/*py*3usr/lib/python3/*-packages/AptUrl/*py*
4usr/lib/python2.?/*-packages/apturl-*.egg-info4usr/lib/python3/*-packages/apturl-*.egg-info
5usr/share/kde4/services5usr/share/kde4/services
6usr/share/locale6usr/share/locale
7usr/share/applications7usr/share/applications
88
=== modified file 'debian/apturl-kde.install'
--- debian/apturl-kde.install 2010-12-17 14:42:22 +0000
+++ debian/apturl-kde.install 2012-06-14 00:37:19 +0000
@@ -1,3 +1,3 @@
1usr/bin/apturl-kde1usr/bin/apturl-kde
2usr/lib/python2.?/*-packages/AptUrl/kde/*py*2usr/lib/python3/*-packages/AptUrl/kde/*py*
3usr/share/apturl/*-qt.ui3usr/share/apturl/*-qt.ui
44
=== modified file 'debian/apturl.install'
--- debian/apturl.install 2011-07-22 12:04:26 +0000
+++ debian/apturl.install 2012-06-14 00:37:19 +0000
@@ -1,5 +1,5 @@
1usr/bin/apturl-gtk1usr/bin/apturl-gtk
2usr/lib/python2.?/*-packages/AptUrl/gtk/*py*2usr/lib/python3/*-packages/AptUrl/gtk/*py*
3usr/lib/python2.?/*-packages/AptUrl/gtk/backend/3usr/lib/python3/*-packages/AptUrl/gtk/backend/
4usr/share/apturl/*-gtk.ui4usr/share/apturl/*-gtk.ui
5usr/share/gconf5usr/share/gconf
66
=== modified file 'debian/changelog'
--- debian/changelog 2012-06-12 16:09:13 +0000
+++ debian/changelog 2012-06-14 00:37:19 +0000
@@ -12,6 +12,27 @@
12 to avoid attempts to destroy it without a thread context.12 to avoid attempts to destroy it without a thread context.
13 - Open temporary synaptic selections file in text mode.13 - Open temporary synaptic selections file in text mode.
1414
15 [ Barry Warsaw ]
16 * Additional Python 3 fixes:
17 + Port setup.py to Python 3.
18 + Use the new python-apt API since the legacy API is not available in
19 Python 3.
20 + ki18n() takes bytes.
21 + Fix relative imports so the code can be run from source.
22 + Fixed some additional packaging paths.
23 + Fix typos in __future__ imports.
24 + Change #! lines to use python3.
25 + Changed debian/control and debian/rules to use python3.
26 + Change debian/compat == 8
27 + apturl now must require python3-aptdaemon.gtk3widgets (i.e. not |
28 synaptic) due to the Python 3 port of update-manager.
29 * Other changes:
30 + Remove the need for threads in the KDE front-end.
31 + Enable running the test suite via `python3 -m unittest discover`
32 + i18n updates.
33 + Various and sundry pyflakes, whitespace, style, line length, and
34 spelling fixes.
35
15 -- Brian Murray <brian@ubuntu.com> Mon, 11 Jun 2012 10:32:52 -070036 -- Brian Murray <brian@ubuntu.com> Mon, 11 Jun 2012 10:32:52 -0700
1637
17apturl (0.5.1ubuntu3) precise; urgency=low38apturl (0.5.1ubuntu3) precise; urgency=low
1839
=== modified file 'debian/compat'
--- debian/compat 2009-09-10 11:45:36 +0000
+++ debian/compat 2012-06-14 00:37:19 +0000
@@ -1,1 +1,1 @@
1718
22
=== modified file 'debian/control'
--- debian/control 2012-03-13 18:45:45 +0000
+++ debian/control 2012-06-14 00:37:19 +0000
@@ -2,23 +2,26 @@
2Section: admin2Section: admin
3Priority: optional3Priority: optional
4Maintainer: Michael Vogt <mvo@ubuntu.com>4Maintainer: Michael Vogt <mvo@ubuntu.com>
5Build-Depends: debhelper (>= 7.0.50~),5Build-Depends: debhelper (>= 8),
6 intltool,6 intltool,
7 python-dev,7 python3-dev,
8 python-distutils-extra8 python3-distutils-extra,
9XS-Python-Version: current9 python3-update-manager,
10 python3-aptdaemon
11X-Python3-Version: >= 3.2
10Standards-Version: 3.9.112Standards-Version: 3.9.1
11Vcs-Bzr: http://bazaar.launchpad.net/~ubuntu-core-dev/apturl/ubuntu/13Vcs-Bzr: http://bazaar.launchpad.net/~ubuntu-core-dev/apturl/ubuntu/
12Vcs-Browser: http://bazaar.launchpad.net/~ubuntu-core-dev/apturl/ubuntu/files14Vcs-Browser: http://bazaar.launchpad.net/~ubuntu-core-dev/apturl/ubuntu/files
1315
14Package: apturl-common16Package: apturl-common
15Architecture: any17Architecture: any
16Depends: ${python:Depends},18Depends: ${python3:Depends},
17 ${shlibs:Depends},19 ${shlibs:Depends},
18 ${misc:Depends},20 ${misc:Depends},
19 python-apt21 python3-apt,
22 python3-update-manager,
23 python3-aptdaemon
20Replaces: apturl (<< 0.3.6ubuntu2)24Replaces: apturl (<< 0.3.6ubuntu2)
21XB-Python-Version: ${python:Versions}
22Description: install packages using the apt protocol - common data25Description: install packages using the apt protocol - common data
23 AptUrl is a simple graphical application that takes an URL (which follows the26 AptUrl is a simple graphical application that takes an URL (which follows the
24 apt-protocol) as a command line option, parses it and carries out the27 apt-protocol) as a command line option, parses it and carries out the
@@ -30,18 +33,17 @@
3033
31Package: apturl34Package: apturl
32Architecture: any35Architecture: any
33Depends: ${python:Depends},36Depends: ${python3:Depends},
34 ${shlibs:Depends},37 ${shlibs:Depends},
35 ${misc:Depends},38 ${misc:Depends},
36 apturl-common (= ${binary:Version}),39 apturl-common (= ${binary:Version}),
37 gnome-icon-theme (>= 2.14.0-1),40 gnome-icon-theme (>= 2.14.0-1),
38 python-gi,41 python3-gi,
39 software-properties-gtk,42 software-properties-gtk,
40 python-aptdaemon.gtk3widgets | synaptic,43 python3-aptdaemon.gtk3widgets,
41 gir1.2-gtk-3.0,44 gir1.2-gtk-3.0,
42 gir1.2-webkit-3.045 gir1.2-webkit-3.0
43Recommends: libgtk2-perl (>= 1:1.130)46Recommends: libgtk2-perl (>= 1:1.130)
44XB-Python-Version: ${python:Versions}
45Description: install packages using the apt protocol - GTK+ frontend47Description: install packages using the apt protocol - GTK+ frontend
46 AptUrl is a simple graphical application that takes an URL (which follows the48 AptUrl is a simple graphical application that takes an URL (which follows the
47 apt-protocol) as a command line option, parses it and carries out the49 apt-protocol) as a command line option, parses it and carries out the
@@ -53,16 +55,15 @@
5355
54Package: apturl-kde56Package: apturl-kde
55Architecture: any57Architecture: any
56Depends: ${python:Depends},58Depends: ${python3:Depends},
57 ${shlibs:Depends},59 ${shlibs:Depends},
58 ${misc:Depends},60 ${misc:Depends},
59 python-qt4,61 python3-pyqt4,
60 python-kde4,62 python3-pykde4,
61 apturl-common (= ${binary:Version}),63 apturl-common (= ${binary:Version}),
62 kdesudo,64 kdesudo,
63 qapt-batch,65 qapt-batch,
64 software-properties-kde (>= 0.75.2)66 software-properties-kde (>= 0.75.2)
65XB-Python-Version: ${python:Versions}
66Description: install packages using the apt protocol - KDE frontend67Description: install packages using the apt protocol - KDE frontend
67 AptUrl is a simple graphical application that takes an URL (which follows the68 AptUrl is a simple graphical application that takes an URL (which follows the
68 apt-protocol) as a command line option, parses it and carries out the69 apt-protocol) as a command line option, parses it and carries out the
6970
=== removed file 'debian/pycompat'
--- debian/pycompat 2007-07-02 09:31:04 +0000
+++ debian/pycompat 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
12
2\ No newline at end of file0\ No newline at end of file
31
=== modified file 'debian/rules'
--- debian/rules 2010-12-17 14:42:22 +0000
+++ debian/rules 2012-06-14 00:37:19 +0000
@@ -1,15 +1,18 @@
1#!/usr/bin/make -f1#!/usr/bin/make -f
2%:2%:
3 dh --with python2 $@3 dh $@ --with python3
44
5override_dh_auto_clean:5override_dh_auto_clean:
6 rm -f AptUrl/Version.py6 rm -f AptUrl/Version.py
77
8override_dh_auto_build:
9 python3 setup.py build
10
8override_dh_auto_install:11override_dh_auto_install:
9 python ./setup.py install --prefix=$(CURDIR)/debian/tmp/usr12 python3 ./setup.py install --root=$(CURDIR)/debian/tmp --install-layout=deb
1013
11override_dh_install:14override_dh_auto_test:
12 dh_install --sourcedir=debian/tmp --fail-missing15 python3 -m unittest discover -vv
1316
1417
15PKG=apturl18PKG=apturl
1619
=== modified file 'po/apturl.pot'
--- po/apturl.pot 2009-01-08 19:46:00 +0000
+++ po/apturl.pot 2012-06-14 00:37:19 +0000
@@ -8,47 +8,52 @@
8msgstr ""8msgstr ""
9"Project-Id-Version: PACKAGE VERSION\n"9"Project-Id-Version: PACKAGE VERSION\n"
10"Report-Msgid-Bugs-To: \n"10"Report-Msgid-Bugs-To: \n"
11"POT-Creation-Date: 2009-01-08 20:26+0100\n"11"POT-Creation-Date: 2012-06-12 17:39-0400\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"14"Language-Team: LANGUAGE <LL@li.org>\n"
15"Language: \n"
15"MIME-Version: 1.0\n"16"MIME-Version: 1.0\n"
16"Content-Type: text/plain; charset=CHARSET\n"17"Content-Type: text/plain; charset=CHARSET\n"
17"Content-Transfer-Encoding: 8bit\n"18"Content-Transfer-Encoding: 8bit\n"
18"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
1919
20#: ../apturl:5020#: ../apturl-gtk:51 ../apturl-kde:54
21msgid "User requested interrupt."21msgid "User requested interrupt."
22msgstr ""22msgstr ""
2323
24#: ../AptUrl/Parser.py:7924#: ../AptUrl/Parser.py:85
25msgid "Non whitelist char in the uri"25msgid "Non whitelist char in the uri"
26msgstr ""26msgstr ""
2727
28#: ../AptUrl/Parser.py:9128#: ../AptUrl/Parser.py:93
29msgid "No ':' in the uri"
30msgstr ""
31
32#: ../AptUrl/Parser.py:117
33msgid "Whitespace in key=value"29msgid "Whitespace in key=value"
34msgstr ""30msgstr ""
3531
36#: ../AptUrl/Parser.py:12332#: ../AptUrl/Parser.py:99
37#, python-format33#, python-format
38msgid "Exception '%s'"34msgid "Exception '%s'"
39msgstr ""35msgstr ""
4036
41#: ../AptUrl/AptUrl.py:7837#: ../AptUrl/Parser.py:109
38#, python-format
39msgid "Url string '%s' too long"
40msgstr ""
41
42#: ../AptUrl/Parser.py:115
43msgid "No ':' in the uri"
44msgstr ""
45
46#: ../AptUrl/AptUrl.py:73
42#, python-format47#, python-format
43msgid "Enabling '%s' failed"48msgid "Enabling '%s' failed"
44msgstr ""49msgstr ""
4550
46#: ../AptUrl/AptUrl.py:9451#: ../AptUrl/AptUrl.py:91
47#, python-format52#, python-format
48msgid "Unknown channel '%s'"53msgid "Unknown channel '%s'"
49msgstr ""54msgstr ""
5055
51#: ../AptUrl/AptUrl.py:9556#: ../AptUrl/AptUrl.py:92
52#, python-format57#, python-format
53msgid "The channel '%s' is not known"58msgid "The channel '%s' is not known"
54msgstr ""59msgstr ""
@@ -88,74 +93,70 @@
88msgid "Can not deal with protocol '%s' "93msgid "Can not deal with protocol '%s' "
89msgstr ""94msgstr ""
9095
91#: ../AptUrl/AptUrl.py:20296#: ../AptUrl/AptUrl.py:205
92#, python-format97#, python-format
93msgid "Package '%s' is virtual."98msgid "Package '%s' is virtual."
94msgstr ""99msgstr ""
95100
96#: ../AptUrl/AptUrl.py:205101#: ../AptUrl/AptUrl.py:208
97#, python-format102#, python-format
98msgid "Could not find package '%s'."103msgid "Could not find package '%s'."
99msgstr ""104msgstr ""
100105
101#: ../AptUrl/AptUrl.py:209106#: ../AptUrl/AptUrl.py:214
102#, python-format107#, python-format
103msgid "Package '%s' is already installed"108msgid "Package '%s' is already installed"
104msgstr ""109msgstr ""
105110
106#: ../AptUrl/AptUrl.py:223111#: ../AptUrl/AptUrl.py:229
107#, python-format112#, python-format
108msgid "Can not install '%s' (%s) "113msgid "Can not install '%s' (%s) "
109msgstr ""114msgstr ""
110115
111#: ../AptUrl/AptUrl.py:228116#: ../AptUrl/AptUrl.py:235
112#, python-format117#, python-format
113msgid "Package '%s' requests minimal version '%s', but only '%s' is available"118msgid "Package '%s' requests minimal version '%s', but only '%s' is available"
114msgstr ""119msgstr ""
115120
116#: ../AptUrl/UI.py:17121#: ../AptUrl/UI.py:16
117msgid "Enable additional components"122msgid "Enable additional components"
118msgstr ""123msgstr ""
119124
120#: ../AptUrl/UI.py:18125#: ../AptUrl/UI.py:24 ../AptUrl/gtk/GtkUI.py:86 ../AptUrl/kde/KdeUI.py:82
121#, python-format
122msgid "Do you want to enable the following component: '%s'?"
123msgid_plural "Do you want to enable the following components: '%s'?"
124msgstr[0] ""
125msgstr[1] ""
126
127#: ../AptUrl/UI.py:25
128msgid "Enable additional software channel"126msgid "Enable additional software channel"
129msgstr ""127msgstr ""
130128
131#: ../AptUrl/UI.py:26129#: ../AptUrl/UI.py:25 ../AptUrl/gtk/GtkUI.py:87 ../AptUrl/kde/KdeUI.py:83
132#, python-format130#, python-format
133msgid "Do you want to enable the following software channel: '%s'?"131msgid "Do you want to enable the following software channel: '%s'?"
134msgstr ""132msgstr ""
135133
136#: ../AptUrl/gtk/GtkUI.py:117134#: ../AptUrl/gtk/GtkUI.py:151 ../AptUrl/kde/KdeUI.py:133
137msgid "Install additional software?"135msgid "Install additional software?"
138msgstr ""136msgstr ""
139137
140#: ../AptUrl/gtk/GtkUI.py:118138#: ../AptUrl/gtk/GtkUI.py:152 ../AptUrl/kde/KdeUI.py:134
141#, python-format139#, python-format
142msgid "Do you want to install package '%s'?"140msgid "Do you want to install package '%s'?"
143msgstr ""141msgstr ""
144142
145#: ../data/apturl.glade.h:1143#. kate: space-indent on; indent-width 4; mixedindent off; indent-mode python;
144#: ../data/apturl-gtk.ui.h:1
146msgid "Description"145msgid "Description"
147msgstr ""146msgstr ""
148147
149#: ../data/apturl.glade.h:2148#: ../data/apturl-gtk.ui.h:2
150msgid "_Install"149msgid "_Install"
151msgstr ""150msgstr ""
152151
153#: ../data/apturl.schemas.in.h:1152#: ../data/apturl.schemas.in.h:1
154msgid "Run the command in a terminal"153msgid "Whether the specified command should handle \"apt\" URLs"
155msgstr ""154msgstr ""
156155
157#: ../data/apturl.schemas.in.h:2156#: ../data/apturl.schemas.in.h:2
158msgid "The command used to handle \"apt\" URLs, if enabled."157msgid ""
158"True if the command specified in the \"command\" key should handle \"apt\" "
159"URLs."
159msgstr ""160msgstr ""
160161
161#: ../data/apturl.schemas.in.h:3162#: ../data/apturl.schemas.in.h:3
@@ -163,17 +164,15 @@
163msgstr ""164msgstr ""
164165
165#: ../data/apturl.schemas.in.h:4166#: ../data/apturl.schemas.in.h:4
166msgid ""167msgid "The command used to handle \"apt\" URLs, if enabled."
167"True if the command specified in the \"command\" key should handle \"apt\" "
168"URLs."
169msgstr ""168msgstr ""
170169
171#: ../data/apturl.schemas.in.h:5170#: ../data/apturl.schemas.in.h:5
171msgid "Run the command in a terminal"
172msgstr ""
173
174#: ../data/apturl.schemas.in.h:6
172msgid ""175msgid ""
173"True if the command used to handle this type of URL should be run in a "176"True if the command used to handle this type of URL should be run in a "
174"terminal."177"terminal."
175msgstr ""178msgstr ""
176
177#: ../data/apturl.schemas.in.h:6
178msgid "Whether the specified command should handle \"apt\" URLs"
179msgstr ""
180179
=== modified file 'setup.py'
--- setup.py 2011-07-22 12:04:26 +0000
+++ setup.py 2012-06-14 00:37:19 +0000
@@ -1,4 +1,4 @@
1#!/usr/bin/env python1#!/usr/bin/env python3
22
3from distutils.core import setup3from distutils.core import setup
4from DistUtilsExtra.command import *4from DistUtilsExtra.command import *
@@ -9,13 +9,13 @@
9# look/set what version we have9# look/set what version we have
10changelog = "debian/changelog"10changelog = "debian/changelog"
11if os.path.exists(changelog):11if os.path.exists(changelog):
12 head = open(changelog).readline()12 with open(changelog, encoding='utf-8') as fp:
13 head = fp.readline()
13 match = re.compile(".*\((.*)\).*").match(head)14 match = re.compile(".*\((.*)\).*").match(head)
14 if match:15 if match:
15 version = match.group(1)16 version = match.group(1)
16 f = open("AptUrl/Version.py", "w")17 with open("AptUrl/Version.py", "w") as fp:
17 f.write("VERSION=\"%s\"\n" % version)18 print('VERSION="{}"'.format(version))
18 f.close()
1919
20GETTEXT_NAME="apturl"20GETTEXT_NAME="apturl"
21I18NFILES = []21I18NFILES = []
2222
=== added file 'tests/__init__.py'
=== renamed file 'tests/apturlparse.py' => 'tests/test_apturl_parse.py'
--- tests/apturlparse.py 2012-06-11 20:34:59 +0000
+++ tests/test_apturl_parse.py 2012-06-14 00:37:19 +0000
@@ -1,17 +1,13 @@
1#!/usr/bin/python
2
3from __future__ import print_function1from __future__ import print_function
42
5import sys
6sys.path.insert(0, "../")
7
8import unittest3import unittest
4
9from AptUrl import Parser5from AptUrl import Parser
106
117
12class TestUrl(unittest.TestCase):8class UrlTests(unittest.TestCase):
13 mapping = { 'kernel':"2.6.23-17-generic",9 mapping = { 'kernel':"2.6.23-17-generic",
14 'distro':"hardy" }10 'distro':"hardy" }
1511
16 testValues = ( ('apt:3ddesktop', [{'package':'3ddesktop',12 testValues = ( ('apt:3ddesktop', [{'package':'3ddesktop',
17 'schema': 'apt'}] ),13 'schema': 'apt'}] ),
@@ -32,11 +28,11 @@
32 ('apt:2vcard?minver=1.0',28 ('apt:2vcard?minver=1.0',
33 [{'package':'2vcard', 'schema': 'apt',29 [{'package':'2vcard', 'schema': 'apt',
34 'minver': '1.0' }]),30 'minver': '1.0' }]),
35 ('apt:owl,newbiedoc,python-pykaraoke?dist=gutsy', 31 ('apt:owl,newbiedoc,python-pykaraoke?dist=gutsy',
36 [{'package':'owl', 'schema':'apt'},32 [{'package':'owl', 'schema':'apt'},
37 {'package':'newbiedoc', 'schema':'apt'},33 {'package':'newbiedoc', 'schema':'apt'},
38 {'package':'python-pykaraoke', 'schema':'apt', 'dist':'gutsy'}]),34 {'package':'python-pykaraoke', 'schema':'apt', 'dist':'gutsy'}]),
39 ('apt:python-pykaraoke?dist=gutsy,owl,newbiedoc', 35 ('apt:python-pykaraoke?dist=gutsy,owl,newbiedoc',
40 [{'package':'python-pykaraoke', 'schema':'apt', 'dist':'gutsy'},36 [{'package':'python-pykaraoke', 'schema':'apt', 'dist':'gutsy'},
41 {'package':'owl', 'schema':'apt'},37 {'package':'owl', 'schema':'apt'},
42 {'package':'newbiedoc', 'schema':'apt'}]),38 {'package':'newbiedoc', 'schema':'apt'}]),
@@ -60,20 +56,16 @@
60 }]),56 }]),
61 )57 )
6258
63 def testValidParse(self):59 def test_valid_parse(self):
64 for (v, e) in self.testValues:60 for v, e in self.testValues:
65 print("Testing: '%s'" % v)61 #print("Testing: '%s'" % v)
66 result_list = Parser.parse(v, self.mapping)62 result_list = Parser.parse(v, self.mapping)
67 for dictionary in e:63 for dictionary in e:
68 for key in dictionary:64 for key in dictionary:
69 self.assertEqual(getattr(result_list[e.index(dictionary)],65 self.assertEqual(getattr(result_list[e.index(dictionary)],
70 key), dictionary[key])66 key), dictionary[key])
7167
72 def test_pkgname_too_long(self):68 def test_pkgname_too_long(self):
73 self.assertRaises(69 self.assertRaises(
74 Parser.InvalidUrlException, Parser.parse,70 Parser.InvalidUrlException, Parser.parse,
75 "apt:" + 100 * "veryverylong")71 "apt:" + 100 * "veryverylong")
76
77
78if __name__ == "__main__":
79 unittest.main()
8072
=== modified file 'tests/test_helpers.py'
--- tests/test_helpers.py 2012-06-11 21:35:40 +0000
+++ tests/test_helpers.py 2012-06-14 00:37:19 +0000
@@ -1,24 +1,17 @@
1#!/usr/bin/python
2
3import sys
4sys.path.insert(0, "../")
5
6import unittest1import unittest
2
7from AptUrl.Helpers import parse_pkg3from AptUrl.Helpers import parse_pkg
84
5
9class MockPkg(object):6class MockPkg(object):
10 def __init__(self, descr):7 def __init__(self, descr):
11 self.description = descr8 self.description = descr
12 self.homepage = None9 self.homepage = None
1310
14class testHelpers(unittest.TestCase):
1511
12class HelpersTest(unittest.TestCase):
16 def test_parse_pkg(self):13 def test_parse_pkg(self):
17 pkgobj = MockPkg("summary\ndescr\n")14 pkgobj = MockPkg("summary\ndescr\n")
18 self.assertEqual(parse_pkg(pkgobj), ('summary','descr\n',None))15 self.assertEqual(parse_pkg(pkgobj), ('summary','descr\n',None))
19 pkgobj = MockPkg("summary only")16 pkgobj = MockPkg("summary only")
20 self.assertEqual(parse_pkg(pkgobj), ('summary only','',None))17 self.assertEqual(parse_pkg(pkgobj), ('summary only','',None))
21
22if __name__ == "__main__":
23 unittest.main()
24

Subscribers

People subscribed via source and target branches