From 6a2dbc6debdffdd8ff179cc12b955e8ea295505b Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Fri, 10 Dec 2010 00:09:17 -0200 Subject: encoding fixes --- g_octave/checksum.py | 7 ++----- g_octave/description.py | 4 +++- g_octave/fetch.py | 2 +- scripts/g-octave | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/g_octave/checksum.py b/g_octave/checksum.py index 22e47d2..13be7ad 100644 --- a/g_octave/checksum.py +++ b/g_octave/checksum.py @@ -29,11 +29,8 @@ config = Config() def sha1_compute(filename): - with open(filename) as fp: - content = fp.read() - if py3k: - content = bytes(content, 'utf-8') - return sha1(content).hexdigest() + with open(filename, 'rb') as fp: + return sha1(fp.read()).hexdigest() def sha1_check(db, p): description = db[p] diff --git a/g_octave/description.py b/g_octave/description.py index 96825fb..dde116d 100644 --- a/g_octave/description.py +++ b/g_octave/description.py @@ -72,8 +72,10 @@ class Description(object): # current key key = None - with open(file, 'r') as fp: + with open(file, 'rb') as fp: for line in fp: + + line = line.decode('iso-8859-15') line_splited = line.split(':') # 'key: value' found? diff --git a/g_octave/fetch.py b/g_octave/fetch.py index a78ed4b..0a35852 100644 --- a/g_octave/fetch.py +++ b/g_octave/fetch.py @@ -72,7 +72,7 @@ class GitHub: ) commits = {} with closing(urllib.urlopen(url)) as fp: - commits = json.load(fp) + commits = json.loads(fp.read().decode('utf-8')) return commits['commits'] def fetch_db(self, branch='master'): diff --git a/scripts/g-octave b/scripts/g-octave index 8951f43..876bcf7 100755 --- a/scripts/g-octave +++ b/scripts/g-octave @@ -285,7 +285,7 @@ def main(): updates.extract() log.info('Checking SHA1 checksums ...') - out.ebegin('Checking SHA1 checksums ...') + out.ebegin('Checking SHA1 checksums') if sha1_check_db(DescriptionTree()): out.eend(0) else: -- cgit v1.2.3-65-gdbad