Author: geissert Date: 2009-11-21 05:53:13 +0000 (Sat, 21 Nov 2009) New Revision: 13336 Modified: lib/python/security_db.py Log: Make the Sources and Packages parser only return the greatest version if more than one entry for the same package is found Modified: lib/python/security_db.py ==================================================================--- lib/python/security_db.py 2009-11-21 05:35:34 UTC (rev 13335) +++ lib/python/security_db.py 2009-11-21 05:53:13 UTC (rev 13336) @@ -484,7 +484,7 @@ re_source = re.compile\ (r''^([a-zA-Z0-9.+-]+)(?:\s+\(([a-zA-Z0-9.+:~-]+)\))?$'') - data = [] + data = {} for pkg in packages: pkg_name = None pkg_version = None @@ -516,8 +516,14 @@ raise SyntaxError\ ("package record for %s lacks Architecture: field" % pkg_name) - data.append((pkg_name, pkg_version, pkg_arch, - pkg_source, pkg_source_version)) + if pkg_name in data: + oversion = debian_support.Version(data[pkg_name][0]) + if oversion < debian_support.Version(pkg_version): + data[pkg_name] = (pkg_version, pkg_arch, + pkg_source, pkg_source_version) + else: + data[pkg_name] = (pkg_version, pkg_arch, + pkg_source, pkg_source_version) return data @@ -580,7 +586,8 @@ self._clearVersions(cursor) def gen(): - for (name, version, archs, source, source_version) in parsed: + for name in parsed.keys(): + (version, archs, source, source_version) = parsed[name] assert source is None assert source_version is None yield name, release, subrelease, archive, version @@ -634,7 +641,8 @@ (release, subrelease, archive, architecture) = match.groups() (unch, parsed) = self._parseFile(cursor, filename) unchanged = unchanged and unch - for (name, version, arch, source, source_version) in parsed: + for name in parsed.keys(): + (version, arch, source, source_version) = parsed[name] if source is None: source = name if source_version is None: