aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvolpino <fox91@anche.no>2012-09-21 19:03:53 +0200
committerCorentin Chary <corentin.chary@gmail.com>2012-10-29 13:06:04 +0100
commit565c5823c1cc35b5c447468d1aa9beecbd0d0e9f (patch)
treeea2004794f253dfcc73fc3b4517385e9f65639ac /pym/euscan
parenteuscan: Removing http cache from TODO (diff)
downloadeuscan-565c5823c1cc35b5c447468d1aa9beecbd0d0e9f.tar.gz
euscan-565c5823c1cc35b5c447468d1aa9beecbd0d0e9f.tar.bz2
euscan-565c5823c1cc35b5c447468d1aa9beecbd0d0e9f.zip
euscan: deb handler - adding support for Packages.gz or Packages.bz2 and version detection fix
Signed-off-by: volpino <fox91@anche.no>
Diffstat (limited to 'pym/euscan')
-rw-r--r--pym/euscan/handlers/deb.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/pym/euscan/handlers/deb.py b/pym/euscan/handlers/deb.py
index 156158b..b559263 100644
--- a/pym/euscan/handlers/deb.py
+++ b/pym/euscan/handlers/deb.py
@@ -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: