summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2014-07-22 19:47:34 +0200
committerHelmut Grohne <helmut@subdivi.de>2014-07-22 19:47:34 +0200
commite15afaf30b1b692603bc761b22670607d54aeda0 (patch)
tree05d48342572809c2001aad0b9a5680df5a9a27d3
parent04597f25729740406775a3dff528c9774c84efd5 (diff)
downloaddebian-dedup-multiarch.tar.gz
let the user choose underspecified packagesmultiarch
-rw-r--r--dedup/templates/choice.html11
-rwxr-xr-xwebapp.py41
2 files changed, 35 insertions, 17 deletions
diff --git a/dedup/templates/choice.html b/dedup/templates/choice.html
new file mode 100644
index 0000000..8a8d373
--- /dev/null
+++ b/dedup/templates/choice.html
@@ -0,0 +1,11 @@
+{% extends "base.html" %}
+{% block title %}confine {{ adjective|e }}{{ package| e }}{% endblock %}
+{% block content -%}
+<h1>confine {{ adjective|e }}package {{ package|e }}</h1>
+<p>Which of the following do you mean?</p>
+<ul>
+{%- for architecture in architectures|sort -%}
+<li><a href="{{ href|format(architecture)|e }}">{{ architecture|e }}</a></li>
+{%- endfor -%}
+</ul>
+{%- endblock -%}
diff --git a/webapp.py b/webapp.py
index e173d60..f5d73ca 100755
--- a/webapp.py
+++ b/webapp.py
@@ -45,6 +45,7 @@ detail_template = jinjaenv.get_template("compare.html")
hash_template = jinjaenv.get_template("hash.html")
index_template = jinjaenv.get_template("index.html")
source_template = jinjaenv.get_template("source.html")
+choice_template = jinjaenv.get_template("choice.html")
def encode_and_buffer(iterator):
buff = b""
@@ -106,14 +107,22 @@ class Application(object):
except HTTPException as e:
return e
- def guess_package(self, package):
+ def choose_package(self, adjective, package, href, basehref):
+ assert href.count("%s") == 1
with contextlib.closing(self.db.cursor()) as cur:
- cur.execute("SELECT architecture, id FROM package WHERE name = ?;",
+ cur.execute("SELECT architecture FROM package WHERE name = ?;",
(package,))
- ret = dict(cur.fetchall())
- if not ret:
+ architectures = set(row[0] for row in cur.fetchall())
+ if not architectures:
raise NotFound()
- return ret
+ if len(architectures) == 1:
+ raise InternalRedirect(basehref % next(iter(architectures)), 302)
+ params = dict(
+ package=package,
+ adjective=adjective,
+ architectures=architectures,
+ href=href)
+ return html_response(choice_template.render(params))
def get_details(self, package, architecture):
with contextlib.closing(self.db.cursor()) as cur:
@@ -155,9 +164,8 @@ class Application(object):
if ':' in package:
package, architecture = package.split(':', 1)
else:
- architecture = min(self.guess_package(package))
- raise InternalRedirect("/binary/%s:%s" % (package, architecture),
- code=302)
+ return self.choose_package("", package, "./%s:%%s" % package,
+ "/binary/%s:%%s" % package)
params = self.get_details(package, architecture)
params["dependencies"] = self.get_dependencies(params["pid"])
params["shared"] = self.cached_sharedstats(params["pid"])
@@ -214,21 +222,20 @@ class Application(object):
yield entry
def show_detail(self, package1, package2):
- guessed = False
if ':' in package1:
package1, architecture1 = package1.split(':', 1)
else:
- architecture1 = min(self.guess_package(package1))
- guessed = True
+ return self.choose_package("first ", package1, "../%s:%%s/%s" %
+ (package1, package2),
+ "/compare/%s:%%s/%s" %
+ (package1, package2))
if ':' in package2:
package2, architecture2 = package2.split(':', 1)
else:
- architecture2 = min(self.guess_package(package2))
- guessed = True
- if guessed:
- raise InternalRedirect("/compare/%s:%s/%s:%s" %
- (package1, architecture1, package2,
- architecture2), code=302)
+ return self.choose_package("second ", package2,
+ "./%s:%%s" % package2,
+ "/compare/%s/%s:%%s" %
+ (package1, package2))
details1 = details2 = self.get_details(package1, architecture1)
if package1 != package2 or architecture1 != architecture2:
details2 = self.get_details(package2, architecture2)