diff options
author | Papoteur <papoteur@mageialinux-online.org> | 2015-10-31 19:53:25 +0100 |
---|---|---|
committer | Papoteur <papoteur@mageialinux-online.org> | 2015-10-31 19:53:25 +0100 |
commit | 85e0448d6d4994a21309a55be13a0a58e84ea761 (patch) | |
tree | be3972c655385af9af626e348de6005c18e3a7b4 /MgaRepo/binrepo.py | |
parent | eba2ac3120cf78d0732757408433da25e1fbbd00 (diff) | |
download | mgarepo-85e0448d6d4994a21309a55be13a0a58e84ea761.tar mgarepo-85e0448d6d4994a21309a55be13a0a58e84ea761.tar.gz mgarepo-85e0448d6d4994a21309a55be13a0a58e84ea761.tar.bz2 mgarepo-85e0448d6d4994a21309a55be13a0a58e84ea761.tar.xz mgarepo-85e0448d6d4994a21309a55be13a0a58e84ea761.zip |
Some updates in binrepo.py, about reading files. #mga17023
Diffstat (limited to 'MgaRepo/binrepo.py')
-rw-r--r-- | MgaRepo/binrepo.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/MgaRepo/binrepo.py b/MgaRepo/binrepo.py index f3aac47..f14de52 100644 --- a/MgaRepo/binrepo.py +++ b/MgaRepo/binrepo.py @@ -13,6 +13,7 @@ import hashlib import urllib.parse import threading import httplib2 + from io import StringIO SOURCES_FILE = "sha1.lst" @@ -34,7 +35,8 @@ def is_binary(path): st = os.stat(path) if st[stat.ST_SIZE] >= maxsize: return True - if open(path).read(0x10000).find('\0') >= 0: + fd = open(path, 'rb') + if b'\0' in bytes(fd.read(0x10000)): return True return False @@ -139,8 +141,8 @@ def parse_sources(path): def file_hash(path): sum = hashlib.sha1() - f = open(path) - while True: + with open(path, 'rb') as f: + while True: block = f.read(4096) if not block: break |