#!/usr/bin/env python # ----------------------------------------------------------------------------- # add_version_headers.py # # Add version header # # Copyright (c) 2017 Yann Herklotz Grave -- MIT License # See file LICENSE for more details # ----------------------------------------------------------------------------- import os import re import sys """@package Add version headers Adds the version headers to every file. """ header = """/* ---------------------------------------------------------------\ ------------- * {0} * * Copyright (c) 2017 Yann Herklotz Grave -- MIT License * See file LICENSE for more details * ---------------------------------------------------------------------------- */ """ def main(argv): for subdir, dirs, files in os.walk(os.getcwd()): if not re.match(".*build.*", subdir): for file_ in files: if re.match(".*[.]cpp$|.*[.]hpp$", file_) and not re.match("^picopng[.]cpp$", file_): print(os.path.join(subdir, file_), end=" ") with open(os.path.join(subdir, file_), 'r') as src_file: src = src_file.read() with open(os.path.join(subdir, file_), 'w') as src_file_lic: src_file_lic.write(header.format(file_)) src_file_lic.write(src) print("-- done") if __name__ == "__main__": main(sys.argv)