summaryrefslogtreecommitdiff
path: root/igor.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2014-10-26 10:34:56 -0400
committerNed Batchelder <ned@nedbatchelder.com>2014-10-26 10:34:56 -0400
commit9b8e67fe48ca5d9d1d6e1a7f03eac625388cc7c7 (patch)
tree721cbf5feaa985459a02535bd20a2a98c1ceb479 /igor.py
parentafc7a3856f9e85d1516822c80deeab0fed41532a (diff)
downloadpython-coveragepy-git-9b8e67fe48ca5d9d1d6e1a7f03eac625388cc7c7.tar.gz
Use with-open everywhere
Diffstat (limited to 'igor.py')
-rw-r--r--igor.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/igor.py b/igor.py
index 6c1c5d1a..4df94cf1 100644
--- a/igor.py
+++ b/igor.py
@@ -168,18 +168,19 @@ def do_check_eol():
checked.add(fname)
line = None
- for n, line in enumerate(open(fname, "rb"), start=1):
- if crlf:
- if "\r" in line:
- print("%s@%d: CR found" % (fname, n))
- return
- if trail_white:
- line = line[:-1]
- if not crlf:
- line = line.rstrip('\r')
- if line.rstrip() != line:
- print("%s@%d: trailing whitespace found" % (fname, n))
- return
+ with open(fname, "rb") as f:
+ for n, line in enumerate(f, start=1):
+ if crlf:
+ if "\r" in line:
+ print("%s@%d: CR found" % (fname, n))
+ return
+ if trail_white:
+ line = line[:-1]
+ if not crlf:
+ line = line.rstrip('\r')
+ if line.rstrip() != line:
+ print("%s@%d: trailing whitespace found" % (fname, n))
+ return
if line is not None and not line.strip():
print("%s: final blank line" % (fname,))