From 65508bb21a8df719cba31f4b84c4574c8f0a35b0 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Fri, 8 May 2015 16:07:59 -0500 Subject: [PATCH] Python2.4 fixes * Ignore accelerate.py * Don't use a lambda or a ternary --- lib/ansible/modules/packaging/os/apt_repository.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/packaging/os/apt_repository.py b/lib/ansible/modules/packaging/os/apt_repository.py index 2ee5819fc4..5153699c8b 100644 --- a/lib/ansible/modules/packaging/os/apt_repository.py +++ b/lib/ansible/modules/packaging/os/apt_repository.py @@ -267,14 +267,18 @@ class SourcesList(object): def dump(self): return '\n'.join([str(i) for i in self]) + def _choice(self, new, old): + if new is None: + return old + return new + def modify(self, file, n, enabled=None, source=None, comment=None): ''' This function to be used with iterator, so we don't care of invalid sources. If source, enabled, or comment is None, original value from line ``n`` will be preserved. ''' valid, enabled_old, source_old, comment_old = self.files[file][n][1:] - choice = lambda new, old: old if new is None else new - self.files[file][n] = (n, valid, choice(enabled, enabled_old), choice(source, source_old), choice(comment, comment_old)) + self.files[file][n] = (n, valid, self._choice(enabled, enabled_old), self._choice(source, source_old), self._choice(comment, comment_old)) def _add_valid_source(self, source_new, comment_new, file): # We'll try to reuse disabled source if we have it.