From 310b23ee8dc79b8601936e40eb268d56a6c9dacd Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Sun, 2 Feb 2014 23:34:28 -0500 Subject: [PATCH] removed with Signed-off-by: Brian Coca --- library/packaging/apt_repository | 40 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/library/packaging/apt_repository b/library/packaging/apt_repository index 96aa6c23948..fc47be7915c 100644 --- a/library/packaging/apt_repository +++ b/library/packaging/apt_repository @@ -178,10 +178,10 @@ class SourcesList(object): def load(self, file): group = [] - with open(file, 'r') as f: - for n, line in enumerate(f): - valid, enabled, source, comment = self._parse(line) - group.append((n, valid, enabled, source, comment)) + f = open(file, 'r') + for n, line in enumerate(f): + valid, enabled, source, comment = self._parse(line) + group.append((n, valid, enabled, source, comment)) self.files[file] = group def save(self, module): @@ -191,22 +191,22 @@ class SourcesList(object): fd, tmp_path = tempfile.mkstemp(prefix=".%s-" % fn, dir=d) os.chmod(os.path.join(fd, tmp_path), 0644) - with os.fdopen(fd, 'w') as f: - for n, valid, enabled, source, comment in sources: - chunks = [] - if not enabled: - chunks.append('# ') - chunks.append(source) - if comment: - chunks.append(' # ') - chunks.append(comment) - chunks.append('\n') - line = ''.join(chunks) - - try: - f.write(line) - except IOError, err: - module.fail_json(msg="Failed to write to file %s: %s" % (tmp_path, unicode(err))) + f = os.fdopen(fd, 'w') + for n, valid, enabled, source, comment in sources: + chunks = [] + if not enabled: + chunks.append('# ') + chunks.append(source) + if comment: + chunks.append(' # ') + chunks.append(comment) + chunks.append('\n') + line = ''.join(chunks) + + try: + f.write(line) + except IOError, err: + module.fail_json(msg="Failed to write to file %s: %s" % (tmp_path, unicode(err))) module.atomic_move(tmp_path, filename) else: del self.files[filename]