From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1521) id BF45D3858030; Wed, 26 Oct 2022 10:09:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BF45D3858030 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666778992; bh=K+Otxyuro6LdZ7CLe5bgB/JVH6gs2JU9YNjBy2xtxG4=; h=From:To:Subject:Date:From; b=EmlCZapsC4QRqaJFic2kt/yX3FOHPZM2rjPd/ZcS/8yVOM4RFcgpPc/wH5SJQq6hi 0C9qfDwZsYuVN6YxtHN6TxFl12OYm+CPDnrOu4Xfl+z/aSnsvYTRKqLJBVfXX4kYtr stciOAACon6dEnehpY8vtES9hpvdOTgcP/ul4lgg= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Frysinger To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: make copyright.py interface a bit nicer X-Act-Checkin: binutils-gdb X-Git-Author: Mike Frysinger X-Git-Refname: refs/heads/master X-Git-Oldrev: 8f97b519fb061a7243344905cc23a77adda6be7a X-Git-Newrev: e5fbca55b28b77eced290e4e681f1d5cd3dafe98 Message-Id: <20221026100952.BF45D3858030@sourceware.org> Date: Wed, 26 Oct 2022 10:09:52 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3De5fbca55b28b= 77eced290e4e681f1d5cd3dafe98 commit e5fbca55b28b77eced290e4e681f1d5cd3dafe98 Author: Mike Frysinger Date: Sat Jan 1 13:02:02 2022 -0500 gdb: make copyright.py interface a bit nicer =20 This way people can run `./copyright.py --help` and get some info as to what this does without it going and modifying the tree. Diff: --- gdb/copyright.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/gdb/copyright.py b/gdb/copyright.py old mode 100644 new mode 100755 index 48192e80560..8d623e6f5c7 --- a/gdb/copyright.py +++ b/gdb/copyright.py @@ -22,7 +22,7 @@ This script updates the list of years in the copyright notices in most files maintained by the GDB project. =20 -Usage: cd src/gdb && python copyright.py +Usage: cd src/gdb && ./copyright.py =20 Always review the output of this script before committing it! A useful command to review the output is: @@ -30,12 +30,14 @@ A useful command to review the output is: This removes the bulk of the changes which are most likely to be correct. """ =20 +import argparse import datetime import locale import os import os.path import subprocess import sys +from typing import List, Optional =20 =20 def get_update_list(): @@ -158,16 +160,25 @@ def may_have_copyright_notice(filename): return False =20 =20 -def main(): +def get_parser() -> argparse.ArgumentParser: + """Get a command line parser.""" + parser =3D argparse.ArgumentParser( + description=3D__doc__, formatter_class=3Dargparse.RawDescriptionHe= lpFormatter + ) + return parser + + +def main(argv: List[str]) -> Optional[int]: """The main subprogram.""" + parser =3D get_parser() + _ =3D parser.parse_args(argv) root_dir =3D os.path.dirname(os.getcwd()) os.chdir(root_dir) =20 if not ( os.path.isdir("gdb") and os.path.isfile("gnulib/import/extra/updat= e-copyright") ): - print("Error: This script must be called from the gdb directory.") - sys.exit(1) + sys.exit("Error: This script must be called from the gdb directory= .") =20 update_list =3D get_update_list() update_files(update_list) @@ -416,4 +427,4 @@ NOT_FSF_LIST =3D ( ) =20 if __name__ =3D=3D "__main__": - main() + sys.exit(main(sys.argv[1:]))