Author: fw Date: 2011-04-24 17:04:37 +0000 (Sun, 24 Apr 2011) New Revision: 16585 Modified: lib/python/debian_support.py lib/python/secmaster.py Log: debian_support.releasecodename(): new function Use it in secmaster.listqueue(). Modified: lib/python/debian_support.py ==================================================================--- lib/python/debian_support.py 2011-04-24 16:57:54 UTC (rev 16584) +++ lib/python/debian_support.py 2011-04-24 17:04:37 UTC (rev 16585) @@ -518,8 +518,25 @@ if _config is not None: return _config _config = json.load(file(findresource("data", "config.json"))) - return _config + return _config +_releasecodename = None +def releasecodename(dist): + """Converts a release name to the code name. + For instance, "sid" and "unstable" are turned into "sid".""" + global _releasecodename + if _releasecodename is None: + result = {} + for (codename, obj) in getconfig()["distributions"].items(): + result[codename] = codename + if "release" in obj: + result[obj["release"]] = codename + _releasecodename = result + try: + return _releasecodename[dist] + except: + raise ValueError("invalid release name: " + repr(dist)) + def test(): # Version assert Version(''0'') < Version(''a'') Modified: lib/python/secmaster.py ==================================================================--- lib/python/secmaster.py 2011-04-24 16:57:54 UTC (rev 16584) +++ lib/python/secmaster.py 2011-04-24 17:04:37 UTC (rev 16585) @@ -43,27 +43,11 @@ if data["version"] != 1: raise IOError("unexpected version number: " + repr(data["version"])) - distributions = debian_support.getconfig()["distributions"] distdict = {} def normdist(dist): - if dist in distdict: - return distdict[dist] if dist.endswith("-security"): - d = dist[:-9] - else: - d = dist - result = None - if d in distributions: - result = d - else: - for (codename, obj) in distributions.items(): - if obj.get("release", None) == d: - result = codename - break - if result is None: - raise ValueError("unknown distribution: " + repr(dist)) - distdict[dist] = result - return result + dist = dist[:-9] + return debian_support.releasecodename(dist) return [(debian_support.BinaryPackage(row[0:5]), set(normdist(dist) for dist in row[5]))