write updates back to same file

This commit is contained in:
pentarctagon 2024-05-12 23:27:04 -05:00 committed by Pentarctagon
parent 7fde3f5ab6
commit f9f67eb6e1

View File

@ -57,14 +57,11 @@ def do_hash(file):
args = argparse.ArgumentParser()
args.add_argument("--repo", default=".", help="The directory of the Wesnoth repository to run this script against.")
args.add_argument("--output", default="output.csv", help="The file to write the results of this script to.")
args.add_argument("--output", default="copyrights.csv", help="The file to write the results of this script to.")
args.add_argument("--input", default="copyrights.csv", help="The file to read the existing copyright data from.")
options = args.parse_args()
os.chdir(options.repo)
with contextlib.suppress(FileNotFoundError):
os.remove(options.output)
csv_data = {}
# Too few fields
missing_fields = []
@ -103,6 +100,9 @@ with open(options.input, encoding="utf-8") as csvfile:
csv_data[file] = row
with contextlib.suppress(FileNotFoundError):
os.remove(options.output)
for root, _, files in os.walk(options.repo):
for filename in files:
filetype = Path(filename).suffix