summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gilbert <floppym@gentoo.org>2012-07-31 16:29:52 -0400
committerMike Gilbert <floppym@gentoo.org>2012-07-31 16:29:52 -0400
commit1be11c73e5a2c0d854957696dabc1566a13061af (patch)
treea7d906038b39894dc10699b409638fe3bf0fd3da
parentAdd sqlite-vacuum script, bug #413295. (diff)
downloadchromium-tools-1be11c73e5a2c0d854957696dabc1566a13061af.tar.gz
chromium-tools-1be11c73e5a2c0d854957696dabc1566a13061af.tar.bz2
chromium-tools-1be11c73e5a2c0d854957696dabc1566a13061af.zip
Python 3 compatibility.
-rwxr-xr-xextract-cves.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/extract-cves.py b/extract-cves.py
index 8769511..4ccfbf7 100755
--- a/extract-cves.py
+++ b/extract-cves.py
@@ -1,16 +1,20 @@
#!/usr/bin/env python
+from __future__ import print_function
+
import re
import sys
-import urllib2
-
+try:
+ from urllib.request import urlopen
+except ImportError:
+ from urllib2 import urlopen
CVE_PATTERN = re.compile('CVE-(\d{4})-(\d+)')
def main(argv):
- response = urllib2.urlopen(argv[0])
- cves = CVE_PATTERN.findall(response.read())
+ response = urlopen(argv[0])
+ cves = CVE_PATTERN.findall(str(response.read()))
years = {}
for year, no in cves:
if year not in years:
@@ -23,7 +27,7 @@ def main(argv):
result.append('CVE-%s-%s' % (year, nos[0]))
else:
result.append('CVE-%s-{%s}' % (year, ','.join(sorted(nos))))
- print ' '.join(result)
+ print(' '.join(result))
return 0