projects
/
litex.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
90c5512
)
mibuild/tools/write_to_file: use context manager
author
Sebastien Bourdeauducq
<sb@m-labs.hk>
Wed, 8 Apr 2015 11:41:54 +0000
(19:41 +0800)
committer
Sebastien Bourdeauducq
<sb@m-labs.hk>
Wed, 8 Apr 2015 11:41:54 +0000
(19:41 +0800)
mibuild/tools.py
patch
|
blob
|
history
diff --git
a/mibuild/tools.py
b/mibuild/tools.py
index 103004435bb1edf33ea514298130e19d79fbb29b..ab690ed06b0db54e22c5dfe9bfde346fe5858a10 100644
(file)
--- a/
mibuild/tools.py
+++ b/
mibuild/tools.py
@@
-19,9
+19,8
@@
def write_to_file(filename, contents, force_unix=False):
newline = None
if force_unix:
newline = "\n"
- f = open(filename, "w", newline=newline)
- f.write(contents)
- f.close()
+ with open(filename, "w", newline=newline) as f:
+ f.write(contents)
def arch_bits():
return struct.calcsize("P")*8