aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2009-11-24 12:45:35 +0000
committerRobin H. Johnson <robbat2@gentoo.org>2009-11-24 12:45:35 +0000
commite1659e557d32fdf793eea3da8a94d79747e6d2a0 (patch)
treeee7e957cd9fb933c5b83b5f2d5f159c155c3e0fd /web
parentNew prefix arch. (diff)
downloadpackages-e1659e557d32fdf793eea3da8a94d79747e6d2a0.tar.gz
packages-e1659e557d32fdf793eea3da8a94d79747e6d2a0.tar.bz2
packages-e1659e557d32fdf793eea3da8a94d79747e6d2a0.zip
Pkgcore 0.5 split out CPV into versioned and unversioned, and we need to deal with that.
Diffstat (limited to 'web')
-rw-r--r--web/controller.py10
-rw-r--r--web/lib/filters.py2
-rw-r--r--web/model.py37
3 files changed, 38 insertions, 11 deletions
diff --git a/web/controller.py b/web/controller.py
index 712fbdc..57fc118 100644
--- a/web/controller.py
+++ b/web/controller.py
@@ -6,12 +6,14 @@ import os, sys, math, time
import cherrypy
from web.model import latest_per_day, \
- build_centerpkg_list
+ build_centerpkg_list, \
+ get_atom
from web.lib.headers import lastmodified_httpheader, \
lastmodified_rightcontent
from web.lib.query_filter import sanitize_query_string
from web.lib import template, filters
-from pkgcore.ebuild.cpv import CPV
+from pkgcore.ebuild.cpv import unversioned_CPV
+from pkgcore.ebuild.cpv import versioned_CPV
# We use short variable names!
# pylint: disable-msg=C0103
@@ -371,14 +373,14 @@ class Root(object):
cat = ''
if len(args) == 1:
pn = args[0]
- cpvtmp = CPV(str('%s/%s' % ('tmp', pn)))
+ cpvtmp = get_atom(str('%s/%s' % ('tmp', pn)))
pn = cpvtmp.package
pagetitle = "/package/%s" % (pn)
elif len(args) == 2:
cat = args[0]
pn = args[1]
cpvstr = '%s/%s' % (cat, pn)
- cpvtmp = CPV(cpvstr)
+ cpvtmp = get_atom(cpvstr)
pn = cpvtmp.package
cat = cpvtmp.category
pagetitle = "/package/%s/%s" % (cat, pn)
diff --git a/web/lib/filters.py b/web/lib/filters.py
index e4a2b41..59e78cf 100644
--- a/web/lib/filters.py
+++ b/web/lib/filters.py
@@ -1,4 +1,4 @@
-#from pkgcore.ebuild.cpv import CPV
+#from pkgcore.ebuild.cpv import unversioned_CPV as CPV
import re, time
from etc.const_data import ConstData
diff --git a/web/model.py b/web/model.py
index 41d6e8e..f768092 100644
--- a/web/model.py
+++ b/web/model.py
@@ -4,7 +4,9 @@ import re, sys
import operator
import cherrypy
-from pkgcore.ebuild.cpv import CPV
+from pkgcore.ebuild.cpv import unversioned_CPV
+from pkgcore.ebuild.cpv import versioned_CPV
+from pkgcore.ebuild.errors import InvalidCPV
from DBUtils.PersistentDB import PersistentDB
from DBUtils.PooledDB import PooledDB
@@ -18,6 +20,29 @@ from web.lib.links import viewcvs_link, \
# We use short variable names!
# pylint: disable-msg=C0103
+def get_atom(cpvstr):
+ """Nasty hack to work around not knowing if an atom is versioned or not"""
+ v_atom = u_atom = None
+ try:
+ v_atom = versioned_CPV(str(cpvstr))
+ except InvalidCPV:
+ pass
+
+ try:
+ u_atom = unversioned_CPV(str(cpvstr))
+ except InvalidCPV:
+ pass
+
+ if u_atom is not None and v_atom is not None:
+ #raise Exception('Ambiguous package atom, could be CAT/PN or CAT/PN-PV: %s' % (cpvstr))
+ return v_atom
+ if v_atom:
+ return v_atom
+ if u_atom:
+ return u_atom
+
+ raise Exception('Not a valid package atom at all: %s' % (cpvstr))
+
def caller_name():
"""Return the name of the function that this was called from"""
return sys._getframe(1).f_code.co_name
@@ -44,7 +69,7 @@ def latest_per_day(cpvlist, daycount, pkgcount = 110):
result.append([last_day, last_day_cpvs])
last_day = cur_day
last_day_cpvs = []
- atom = CPV(str(cpvstr))
+ atom = get_atom(str(cpvstr))
pnpv = optimal_collapse(atom, 16, 6, '&hellip;')
last_day_cpvs.append((pnpv, atom.key))
pkgno += 1
@@ -61,7 +86,7 @@ def build_centerpkg_list(latest_entries,
shown_cp = []
# dummy is mtime
for cpv, dummy in latest_entries:
- atom = CPV(str(cpv))
+ atom = get_atom(str(cpv))
if 'use_fullver' in kwds and kwds['use_fullver']:
version_check = atom.cpvstr
else:
@@ -516,7 +541,7 @@ class PackageDB(object):
def _get_package_details_cpv(self, cpvstr):
"""get package details with versionfiltered keywords (uncached)"""
- atom = CPV(str(cpvstr))
+ atom = get_atom(str(cpvstr))
(cat, pn) = (atom.category, atom.package)
pkg_metadata = self.get_package_details(cat, pn)
if pkg_metadata is None:
@@ -600,7 +625,7 @@ class PackageDB(object):
row = cursor.fetchone()
ebuildchangeutc = datetime.datetime.utcfromtimestamp(row[0])
- package_details = { 'atom': CPV(str(cp)),
+ package_details = { 'atom': get_atom(str(cp)),
'license': pkglicense,
'homepage': homepage,
'description': description,
@@ -658,7 +683,7 @@ class PackageDB(object):
arch = str(row[1])
mode = str(row[2])
if not query.fullver:
- current_cpv = CPV(cpv)
+ current_cpv = get_atom(cpv)
else:
current_cpv = query