Index: packager.py |
diff --git a/packager.py b/packager.py |
index 99fd4b3c8b8788323c67990426d1a0b9bd2cde6d..71ac371faf5f11b623c99ff9ed3aebbc2f8ce747 100644 |
--- a/packager.py |
+++ b/packager.py |
@@ -95,11 +95,11 @@ class Files(dict): |
if (skip == None or file not in skip) and self.isIncluded(name): |
self.read(os.path.join(path, file), name) |
else: |
- file = open(path, 'rb') |
- if relpath in self: |
- print >>sys.stderr, 'Warning: File %s defined multiple times' % relpath |
- self[relpath] = file.read() |
- file.close() |
+ with open(path, 'rb') as file: |
+ if relpath in self: |
+ print >>sys.stderr, 'Warning: File %s defined multiple times' % relpath |
+ else: |
+ self[relpath] = file.read() |
def readMappedFiles(self, mappings): |
for item in mappings: |