aboutsummaryrefslogtreecommitdiff
path: root/contrib/devtools
diff options
context:
space:
mode:
authorbrunoerg <brunoely.gc@gmail.com>2022-04-26 14:39:07 -0300
committerbrunoerg <brunoely.gc@gmail.com>2022-04-27 20:04:33 -0300
commit027aab663aaca32818051d456c3900326377281c (patch)
tree124f38ed34778b6d4c53af634c65017e52e6e862 /contrib/devtools
parent269dcad16e3d69f22c7a669c624beeb405111bbe (diff)
downloadbitcoin-027aab663aaca32818051d456c3900326377281c.tar.xz
test, contrib, refactor: use `with` when opening a file
Diffstat (limited to 'contrib/devtools')
-rwxr-xr-xcontrib/devtools/copyright_header.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/contrib/devtools/copyright_header.py b/contrib/devtools/copyright_header.py
index 38f3df77c9..e20eb4b0d2 100755
--- a/contrib/devtools/copyright_header.py
+++ b/contrib/devtools/copyright_header.py
@@ -320,15 +320,13 @@ def get_most_recent_git_change_year(filename):
################################################################################
def read_file_lines(filename):
- f = open(filename, 'r', encoding="utf8")
- file_lines = f.readlines()
- f.close()
+ with open(filename, 'r', encoding="utf8") as f:
+ file_lines = f.readlines()
return file_lines
def write_file_lines(filename, file_lines):
- f = open(filename, 'w', encoding="utf8")
- f.write(''.join(file_lines))
- f.close()
+ with open(filename, 'w', encoding="utf8") as f:
+ f.write(''.join(file_lines))
################################################################################
# update header years execution