From 71afb9e43213b86cef9748469fa225dd10342548 Mon Sep 17 00:00:00 2001 From: Rike-Benjamin Schuppner Date: Mon, 10 Jun 2013 15:52:04 +0200 Subject: [PATCH] Use with guard for file reads. --- lib/ansible/inventory/ini.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ansible/inventory/ini.py b/lib/ansible/inventory/ini.py index 8412f4acac..1c7ae58bf1 100644 --- a/lib/ansible/inventory/ini.py +++ b/lib/ansible/inventory/ini.py @@ -33,11 +33,11 @@ class InventoryParser(object): def __init__(self, filename=C.DEFAULT_HOST_LIST): - fh = open(filename) - self.lines = fh.readlines() - self.groups = {} - self.hosts = {} - self._parse() + with open(filename) as fh: + self.lines = fh.readlines() + self.groups = {} + self.hosts = {} + self._parse() def _parse(self):