From cc9ec05d11e6f75081c19edae61fbd49f472102e Mon Sep 17 00:00:00 2001 From: "mila@ringwald.ch" Date: Fri, 6 Feb 2015 14:16:26 +0000 Subject: [PATCH] fixed temp file name generation --- tools/update_copyright.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/tools/update_copyright.py b/tools/update_copyright.py index 76351ce30..163d51674 100644 --- a/tools/update_copyright.py +++ b/tools/update_copyright.py @@ -53,17 +53,19 @@ class State: SearchCopyrighter = 1 SearchEndComment = 2 -def updateCopyright(file_name): +def updateCopyright(dir_name, file_name): print file_name, ": Update copyright" - outfile = "tmp_"+file_name + infile = dir_name + "/" + file_name + outfile = dir_name + "/tmp_" + file_name + with open(outfile, 'w') as fout: fout.write(copyright) bufferComment = "" state = State.SearchStartComment - with open(file_name, 'rb') as fin: + with open(infile, 'rb') as fin: for line in fin: if state == State.SearchStartComment: parts = re.match('\s*(/\*).*',line, re.I) @@ -92,7 +94,7 @@ def updateCopyright(file_name): if parts: state = State.SearchStartComment - os.rename(outfile, file_name) + os.rename(outfile, infile) def requiresCopyrightUpdate(file_name): global copyrightString, onlyDumpDifferentCopyright @@ -119,17 +121,14 @@ def requiresCopyrightUpdate(file_name): return False -file_name = "att_server.h" -updateCopyright(file_name) - -# for root, dirs, files in os.walk('../', topdown=True): -# dirs[:] = [d for d in dirs if d not in ignoreFolders] -# files[:] = [f for f in files if f not in ignoreFiles] -# for f in files: -# if f.endswith(".h") or f.endswith(".c"): -# file_name = root + "/" + f -# if requiresCopyrightUpdate(file_name): -# updateCopyright(file_name) +for root, dirs, files in os.walk('../', topdown=True): + dirs[:] = [d for d in dirs if d not in ignoreFolders] + files[:] = [f for f in files if f not in ignoreFiles] + for f in files: + if f.endswith(".h") or f.endswith(".c"): + file_name = root + "/" + f + if requiresCopyrightUpdate(file_name): + updateCopyright(file_name) \ No newline at end of file