[Bf-blender-cvs] [b53bfff] buildbot_linux_cmake: use context for file open (wont complain of not closing)

Campbell Barton noreply at git.blender.org
Wed Dec 2 14:07:01 CET 2015


Commit: b53bfff41dc413c70e73c8db421b11d4a6814b3c
Author: Campbell Barton
Date:   Thu Dec 3 00:00:36 2015 +1100
Branches: buildbot_linux_cmake
https://developer.blender.org/rBb53bfff41dc413c70e73c8db421b11d4a6814b3c

use context for file open (wont complain of not closing)

===================================================================

M	build_files/buildbot/slave_pack.py

===================================================================

diff --git a/build_files/buildbot/slave_pack.py b/build_files/buildbot/slave_pack.py
index 203d53b..8c7e732 100644
--- a/build_files/buildbot/slave_pack.py
+++ b/build_files/buildbot/slave_pack.py
@@ -42,13 +42,15 @@ upload_filename = None  # Name of the archive to be uploaded
 upload_filepath = None  # Filepath to be uploaded to the server
                         # (this folder will be packed)
 
+
 def parse_header_file(filename, define):
     import re
     regex = re.compile("^#\s*define\s+%s\s+(.*)" % define)
-    for l in open(filename, "r"):
-        match = regex.match(l)
-        if match:
-            return match.group(1)
+    with open(filename, "r") as file:
+        for l in file:
+            match = regex.match(l)
+            if match:
+                return match.group(1)
     return None




More information about the Bf-blender-cvs mailing list