diff options
author | Patrick Mezard <pmezard@gmail.com> | 2011-01-23 15:21:56 +0100 |
---|---|---|
committer | Andrej Shadura <andrew@shadura.me> | 2018-07-06 16:43:44 +0200 |
commit | bb74d99f364f60ff6b3364e308357c8bc438eb11 (patch) | |
tree | 4dee735a1fd8e2f0bafe6757d40793a887ccdff8 | |
parent | 43c6b2be8c07297969e3de3f620ea1890999f660 (diff) |
crpatch: simplify header methods with any()
-rw-r--r-- | git_crecord/crpatch.py | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/git_crecord/crpatch.py b/git_crecord/crpatch.py index 2f45d70..20866cc 100644 --- a/git_crecord/crpatch.py +++ b/git_crecord/crpatch.py @@ -230,10 +230,7 @@ class uiheader(patchnode): Otherwise return False. """ - for h in self.header: - if h.startswith('GIT binary patch'): - return True - return False + return any(h.startswith('GIT binary patch') for h in self.header) def pretty(self, fp): for h in self.header: @@ -267,10 +264,7 @@ class uiheader(patchnode): smaller than the size of the entire file.) Otherwise return False """ - for h in self.header: - if self.allhunks_re.match(h): - return True - return False + return any(self.allhunks_re.match(h) for h in self.header) def files(self): fromfile, tofile = self.diff_re.match(self.header[0]).groups() @@ -288,9 +282,7 @@ class uiheader(patchnode): return '<header %s>' % (' '.join(map(repr, self.files()))) def special(self): - for h in self.header: - if self.special_re.match(h): - return True + return any(self.special_re.match(h) for h in self.header) @property def changetype(self): |