--- a/scripts/uninstall-debugclients.py Thu Nov 09 09:37:23 2023 +0100 +++ b/scripts/uninstall-debugclients.py Thu Nov 09 11:23:48 2023 +0100 @@ -10,15 +10,14 @@ Unnstallation script for the eric debug clients. """ +import argparse import contextlib -import getopt import os import shutil import sys import sysconfig # Define the globals. -progName = None currDir = os.getcwd() modDir = None pyModDir = None @@ -42,22 +41,6 @@ sys.exit(rcode) -def usage(rcode=2): - """ - Display a usage message and exit. - - @param rcode return code passed back to the calling process (integer) - """ - global progName - - print("Usage:") - print(" {0} [-h]".format(progName)) - print("where:") - print(" -h display this help message") - - exit(rcode) - - def initGlobals(): """ Module function to set the values of globals that need more than a @@ -94,26 +77,25 @@ exit(7) -def main(argv): +def createArgumentParser(): + """ + Function to create an argument parser. + + @return created argument parser object + @rtype argparse.ArgumentParser + """ + parser = argparse.ArgumentParser(description="Uninstall eric7 debug client.") + return parser + + +def main(): """ The main function of the script. - - @param argv the list of command line arguments. """ initGlobals() - # Parse the command line. - global progName - progName = os.path.basename(argv[0]) - - try: - optlist, args = getopt.getopt(argv[1:], "hy") - except getopt.GetoptError: - usage() - - for opt, _arg in optlist: - if opt in ["-h", "--help"]: - usage(0) + parser = createArgumentParser() + parser.parse_args() print("\nUninstalling eric debug clients ...") uninstallEricDebugClients() @@ -125,7 +107,7 @@ if __name__ == "__main__": try: - main(sys.argv) + main() except SystemExit: raise except Exception: