diff options
author | Papoteur <papoteur@mageialinux-online.org> | 2015-11-01 21:29:18 +0100 |
---|---|---|
committer | Papoteur <papoteur@mageialinux-online.org> | 2015-11-01 21:29:18 +0100 |
commit | 11c8e8abb541f4877a57c284342a6540be8478ae (patch) | |
tree | 1b7c4f48b74fc5d7c37ae7235b5451e1abc559ec | |
parent | 42e337ed4f146e6cb97d2c8acacfafba64416938 (diff) | |
download | mgarepo-11c8e8abb541f4877a57c284342a6540be8478ae.tar mgarepo-11c8e8abb541f4877a57c284342a6540be8478ae.tar.gz mgarepo-11c8e8abb541f4877a57c284342a6540be8478ae.tar.bz2 mgarepo-11c8e8abb541f4877a57c284342a6540be8478ae.tar.xz mgarepo-11c8e8abb541f4877a57c284342a6540be8478ae.zip |
Be sure that files are read even if encoded in utf-8
-rw-r--r-- | MgaRepo/binrepo.py | 2 | ||||
-rw-r--r-- | MgaRepo/log.py | 11 |
2 files changed, 6 insertions, 7 deletions
diff --git a/MgaRepo/binrepo.py b/MgaRepo/binrepo.py index f14de52..89679b0 100644 --- a/MgaRepo/binrepo.py +++ b/MgaRepo/binrepo.py @@ -125,7 +125,7 @@ def import_binaries(topdir, pkgname): def parse_sources(path): entries = {} try: - f = open(path) + f = open(path, encoding="utf-8") except IOError: return [] diff --git a/MgaRepo/log.py b/MgaRepo/log.py index fa7ac62..40302bc 100644 --- a/MgaRepo/log.py +++ b/MgaRepo/log.py @@ -553,12 +553,11 @@ def get_old_log(pkgdirurl): else: logfile = os.path.join(tmpdir, "log") if os.path.isfile(logfile): - file = open(logfile) - chlog.write("\n") # TODO needed? - log = file.read() - log = escape_macros(log) - chlog.write(log) - file.close() + with open(logfile, 'r', encoding = 'utf-8') as lf: + chlog.write("\n") # TODO needed? + log = lf.read() + log = escape_macros(log) + chlog.write(log) finally: if os.path.isdir(tmpdir): shutil.rmtree(tmpdir) |