From 5f63989ee0b3d77d2b484ae712ac370f84a3ba68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Fri, 20 Jan 2023 10:51:10 +0000 Subject: Update authors file in place Instead of having AUTHORS.src and copying that to a new AUTHORS file with git log information appended to that have a single AUHTORS file and update it in place with git log info. --- tools/generate_authors.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'tools') diff --git a/tools/generate_authors.py b/tools/generate_authors.py index 6d020d954c..a74ef1c40b 100755 --- a/tools/generate_authors.py +++ b/tools/generate_authors.py @@ -107,15 +107,23 @@ def generate_git_contributors_text(contributors_emails, git_authors_emails): return "\n".join(output_lines) -def main(): - stdoutu8 = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') +# Read authos file until we find gitlog entries, then stop +def read_authors(parsed_args): + lines = [] + with open(parsed_args.authors[0], 'r', encoding='utf-8') as fh: + for line in fh.readlines(): + if '= From git log =' in line: + break + lines.append(line) + return ''.join(lines) + +def main(): parser = argparse.ArgumentParser(description="Generate the AUTHORS file combining existing AUTHORS file with git commit log.") parser.add_argument("authors", metavar='authors', nargs=1, help="path to AUTHORS file") parsed_args = parser.parse_args() - with open(parsed_args.authors[0], encoding='utf-8') as fh: - author_content = fh.read() + author_content = read_authors(parsed_args) # Collect the listed contributors emails so that we don't duplicate them # in the listing of git contributors @@ -125,9 +133,11 @@ def main(): git_contributors_text = generate_git_contributors_text(contributors_emails, git_authors_emails) # Now we can write our output: - git_contributor_header = '\n\n= From git log =\n\n' + git_contributor_header = '= From git log =\n\n' output = author_content + git_contributor_header + git_contributors_text + '\n' - stdoutu8.write(output) + + with open(parsed_args.authors[0], 'w', encoding='utf-8') as fh: + fh.write(output) if __name__ == '__main__': -- cgit v1.2.3