diff options
author | Augie Fackler <augie@google.com> | 2016-08-05 14:00:14 -0400 |
---|---|---|
committer | Andrej Shadura <andrew@shadura.me> | 2018-07-06 16:33:54 +0200 |
commit | 43c6b2be8c07297969e3de3f620ea1890999f660 (patch) | |
tree | c2f03ae6c665732a55924e3e21e88a27cd466359 | |
parent | ec11e17bbfdec9ebbb641b665f9f8c85a28cc529 (diff) |
crpatch: use `iter(callable, sentinel)` instead of while True
-rw-r--r-- | git_crecord/crpatch.py | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/git_crecord/crpatch.py b/git_crecord/crpatch.py index 2579e3b..2f45d70 100644 --- a/git_crecord/crpatch.py +++ b/git_crecord/crpatch.py @@ -29,11 +29,7 @@ class linereader(object): return self.fp.readline().decode('UTF-8') def __iter__(self): - while True: - l = self.readline() - if not l: - break - yield l + return iter(self.readline, '') def scanpatch(fp): """like patch.iterhunks, but yield different events @@ -48,10 +44,7 @@ def scanpatch(fp): def scanwhile(first, p): """scan lr while predicate holds""" lines = [first] - while True: - line = lr.readline() - if not line: - break + for line in iter(lr.readline, ''): if p(line): lines.append(line) else: @@ -59,10 +52,7 @@ def scanpatch(fp): break return lines - while True: - line = lr.readline() - if not line: - break + for line in iter(lr.readline, ''): if line.startswith('diff --git a/'): def notheader(line): s = line.split(None, 1) |