From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id EA7053858C83 for ; Tue, 25 Oct 2022 01:26:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EA7053858C83 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [10.0.0.11] (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 47F631E0CB; Mon, 24 Oct 2022 21:26:55 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1666661215; bh=HzjEw0TukHzmb8pVeaWSbMtdjyNC7oNdwi/HEjdLEM0=; h=Date:Subject:To:References:From:In-Reply-To:From; b=dQLslnKGvArvpx3ifwPjs9JHxbMdC8+Yv4ujItlq8KC/Pj/PcHNHgTCWgeobR2Ffk PpREbi8YooG6f6YrcoUKfDi/OJrpUb9C8wuJ621M1Trc0okT3iGdCUppE53iV1oxSg cbXVCiFSjQgrj+ODPIXUB+pl78gxUgnRluKfUQ/U= Message-ID: <968554d0-c74d-a5fe-daad-61449b140aa0@simark.ca> Date: Mon, 24 Oct 2022 21:26:54 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH] gdb: make copyright.py interface a bit nicer Content-Language: en-US To: Mike Frysinger , gdb-patches@sourceware.org References: <20220101181456.25684-1-vapier@gentoo.org> From: Simon Marchi In-Reply-To: <20220101181456.25684-1-vapier@gentoo.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2022-01-01 13:14, Mike Frysinger via Gdb-patches wrote: > This way people can run `./copyright.py --help` and get some info as > to what this does without it going and modifying the tree. > --- > gdb/copyright.py | 21 ++++++++++++++++----- > 1 file changed, 16 insertions(+), 5 deletions(-) > mode change 100644 => 100755 gdb/copyright.py > > diff --git a/gdb/copyright.py b/gdb/copyright.py > old mode 100644 > new mode 100755 > index 0de15b8a3053..a78f7f2aa9b0 > --- 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. > > -Usage: cd src/gdb && python copyright.py > +Usage: cd src/gdb && ./copyright.py > > 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. > """ > > +import argparse > import datetime > import locale > import os > import os.path > import subprocess > import sys > +from typing import List, Optional > > > def get_update_list(): > @@ -158,16 +160,25 @@ def may_have_copyright_notice(filename): > return False > > > -def main(): > +def get_parser() -> argparse.ArgumentParser: > + """Get a command line parser.""" > + parser = argparse.ArgumentParser( > + description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter > + ) > + return parser > + > + > +def main(argv: List[str]) -> Optional[int]: > """The main subprogram.""" > + parser = get_parser() > + _ = parser.parse_args(argv) > root_dir = os.path.dirname(os.getcwd()) > os.chdir(root_dir) > > if not ( > os.path.isdir("gdb") and os.path.isfile("gnulib/import/extra/update-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.") > > update_list = get_update_list() > update_files(update_list) > @@ -416,4 +427,4 @@ NOT_FSF_LIST = ( > ) > > if __name__ == "__main__": > - main() > + sys.exit(main(sys.argv[1:])) LGTM, thanks. Approved-By: Simon Marchi Simon