aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorLei Zhang <antiagainst@google.com>2016-08-05 10:45:36 -0400
committerLei Zhang <antiagainst@gmail.com>2016-08-06 22:15:41 -0400
commit620166acfcbc433d82af4095a88cb689eb70abce (patch)
tree8e38a92ede6ac8366f595dc5c850555b32452d2e /utils
parentb077f3ee22e51f54a6bfcd1193bb8ed09c0660af (diff)
downloadshaderc-620166acfcbc433d82af4095a88cb689eb70abce.tar.gz
Use with clause to handle files.
Diffstat (limited to 'utils')
-rwxr-xr-xutils/update_build_version.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/utils/update_build_version.py b/utils/update_build_version.py
index fd600a1..b1a4b0b 100755
--- a/utils/update_build_version.py
+++ b/utils/update_build_version.py
@@ -110,9 +110,13 @@ def main():
'"{}\\n"\n'.format(get_version_string(p, d))
for (p, d) in zip(projects, sys.argv[1:])
])
- if os.path.isfile(OUTFILE) and new_content == open(OUTFILE, 'r').read():
- sys.exit(0)
- open(OUTFILE, 'w').write(new_content)
+
+ if os.path.isfile(OUTFILE):
+ with open(OUTFILE, 'r') as f:
+ if new_content == f.read():
+ return
+ with open(OUTFILE, 'w') as f:
+ f.write(new_content)
if __name__ == '__main__':