From 3164d40e2247d42537aef8e80fa7e048e14bec9f Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 11 Nov 2019 05:40:22 -0500 Subject: use open context managers in more places Use open() as a context manager to simplify the close logic and make the code easier to read & understand. This is also more Pythonic. Change-Id: I579d03cca86f99b2c6c6a1f557f6e5704e2515a7 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/244734 Reviewed-by: David Pursehouse Tested-by: Mike Frysinger --- subcmds/manifest.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'subcmds/manifest.py') diff --git a/subcmds/manifest.py b/subcmds/manifest.py index 768f072e..9c1b3f0c 100644 --- a/subcmds/manifest.py +++ b/subcmds/manifest.py @@ -40,10 +40,9 @@ in a Git repository for use during future 'repo init' invocations. helptext = self._helpDescription + '\n' r = os.path.dirname(__file__) r = os.path.dirname(r) - fd = open(os.path.join(r, 'docs', 'manifest-format.md')) - for line in fd: - helptext += line - fd.close() + with open(os.path.join(r, 'docs', 'manifest-format.md')) as fd: + for line in fd: + helptext += line return helptext def _Options(self, p): -- cgit v1.2.3-54-g00ecf