From: Michał Bartoszkiewicz Date: Wed, 5 Oct 2011 18:12:53 +0000 (+0200) Subject: Użycie with z open. X-Git-Tag: v1.0~8 X-Git-Url: https://git.bzium.org/embe/man-symlinker.git/commitdiff_plain/c53e09413b0bc737ee510ec5aa18a6ec7406957d?ds=inline Użycie with z open. --- diff --git a/man-symlinker.py b/man-symlinker.py index 91a31ed..b4ef047 100755 --- a/man-symlinker.py +++ b/man-symlinker.py @@ -17,13 +17,13 @@ def process_file(name): return False category = m.group(1) dir_name = 'man' + category - f = open(name, 'r') - s = f.read(MAX_LEN+1) - if len(s) > MAX_LEN: - return False - s = s.strip() - if '\n' in s: - return False + with open(name, 'r') as f: + s = f.read(MAX_LEN+1) + if len(s) > MAX_LEN: + return False + s = s.strip() + if '\n' in s: + return False m = SO_RE.search(s) if not m: return False