euscan: deb handler - adding support for Packages.gz or Packages.bz2 and version detection fix

Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
volpino 2012-09-21 19:03:53 +02:00 committed by Corentin Chary
parent ef20139730
commit 565c5823c1
2 changed files with 13 additions and 7 deletions

3
TODO
View File

@ -38,8 +38,7 @@ euscan
### handlers
- remote-id type deb repository:
- Fix handler to support Packages.gz or Packages.bz2
- find out how to get download url
- find out how to get download url (not sure it's possible)
### remote-id
- Propose new remote-id: deb

View File

@ -1,5 +1,7 @@
import urllib
import re
import bz2
import zlib
import portage
@ -24,17 +26,22 @@ def scan_pkg(pkg, options):
fp = urllib.urlopen(packages_url)
content = fp.read()
# TODO: Add support for .gz and .bz2 Packages file
# Support for .gz and .bz2 Packages file
if packages_url.endswith(".bz2"):
content = bz2.decompress(content)
if packages_url.endswith(".gz"):
content = zlib.decompress(content, 16 + zlib.MAX_WBITS)
content = content.split("\n\n")
result = []
for package_info in content:
for line in package_info.split("\n"):
res = re.search("^Version: (.*)$", line)
if res:
result.append(res.group(1))
package_line = re.search(r"^Package: (.*)$", package_info, re.M)
version_line = re.search(r"^Version: (.*)$", package_info, re.M)
if package_line and package_line.group(1) == package_name:
if version_line:
result.append(version_line.group(1))
ret = []
for up_pv in result: