[PATCH 1/2] Make aap Python 2.6 compatible
Leandro Lucarella <[email protected]> Mon, 6 Apr 2009 11:19:00 -0300
| Newsgroups | gmane.comp.tools.aap.devel |
|---|---|
| Message-ID | <[email protected]> |
From: Leandro Lucarella <[email protected]> --- Filetype.py | 16 ++++++++-------- Sign.py | 11 ++++++++--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Filetype.py b/Filetype.py index 74765e1..9f61730 100755 --- a/Filetype.py +++ b/Filetype.py @@ -1414,12 +1414,12 @@ def ft_add_rules(dtstr, recipe_line_nr, recdict = None): rline = items[1] rline_len = len(rline) # isolate first argument, which may be in quotes - as = 0 - if as < rline_len: - if rline[as] == '"' or rline[as] == "'": - quote = rline[as] - as = as + 1 - ae = as + as_ = 0 + if as_ < rline_len: + if rline[as_] == '"' or rline[as_] == "'": + quote = rline[as_] + as_ = as_ + 1 + ae = as_ while ae < rline_len and rline[ae] != quote: ae = ae + 1 if ae == rline_len: @@ -1427,11 +1427,11 @@ def ft_add_rules(dtstr, recipe_line_nr, recdict = None): % (line_idx + recipe_line_nr, line)) n = ae + 1 else: - ae = as + ae = as_ while ae < rline_len and rline[ae] != ' ' and rline[ae] != '\t': ae = ae + 1 n = ae - arg1 = rline[as:ae] + arg1 = rline[as_:ae] else: arg1 = '' n = rline_len diff --git a/Sign.py b/Sign.py index 171b3ab..378e236 100644 --- a/Sign.py +++ b/Sign.py @@ -11,7 +11,12 @@ import os import os.path import string -import md5 +try: + import hashlib +except ImportError: # Backward compatilibity + import md5 + class hashlib: + md5 = md5.new import time from Util import * @@ -272,7 +277,7 @@ def check_md5(recdict, fname, msg = 1): try: f = open(fname, "rb") - m = md5.new() + m = hashlib.md5() while 1: # Read big blocks at a time for speed, but don't read the whole # file at once to reduce memory usage. @@ -404,7 +409,7 @@ def check_c_md5(recdict, fname): def buildcheckstr2sign(str): """Compute a signature from a string for the buildcheck.""" - return hexdigest(md5.new(str)) + return hexdigest(hashlib.md5(str)) def _sign_lookup(signatures, name, key): -- 1.6.2.1 ------------------------------------------------------------------------------