def main(): # mccabe:disable=MC0001 """This is the entry point for pyghdl.cli.dom written as a function. 1. It extracts common flags from the script's arguments list, before :py:class:`~argparse.ArgumentParser` is fully loaded. 2. It creates an instance of DOM test application and hands over to a class based execution. All is wrapped in a big ``try..except`` block to catch every unhandled exception. 3. Shutdown the script and return its exit code. """ from sys import argv as sys_argv debug = "-d" in sys_argv verbose = "-v" in sys_argv quiet = "-q" in sys_argv try: # handover to a class instance app = Application(debug, verbose, quiet) app.Run() app.exit() except PrettyPrintException as ex: print("PP: {!s}".format(ex)) LineTerminal.exit() except DOMException as ex: print("DOM: {!s}".format(ex)) ex2: LibGHDLException = ex.__cause__ if ex2 is not None: for message in ex2.InternalErrors: print("libghdl: {message}".format(message=message)) LineTerminal.exit(0) LineTerminal.exit(6) except LibGHDLException as ex: print("LIB: {!s}".format(ex)) for message in ex.InternalErrors: print(" {message}".format(message=message)) LineTerminal.exit(5) except GHDLBaseException as ex: LineTerminal.printExceptionBase(ex) except NotImplementedError as ex: LineTerminal.printNotImplementedError(ex) # except ImportError as ex: # printImportError(ex) except Exception as ex: LineTerminal.printException(ex)
def main(): # mccabe:disable=MC0001 """This is the entry point for pyVHDLParser written as a function. 1. It extracts common flags from the script's arguments list, before :py:class:`~argparse.ArgumentParser` is fully loaded. 2. It creates an instance of VHDLParser and hands over to a class based execution. All is wrapped in a big ``try..except`` block to catch every unhandled exception. 3. Shutdown the script and return its exit code. """ from sys import argv as sys_argv debug = "-d" in sys_argv verbose = "-v" in sys_argv quiet = "-q" in sys_argv try: # handover to a class instance app = Application(debug, verbose, quiet) app.Run() app.exit() # except (CommonException, ConfigurationException) as ex: # print("{RED}ERROR:{NOCOLOR} {message}".format(message=ex.message, **Init.Foreground)) # cause = ex.__cause__ # if isinstance(cause, FileNotFoundError): # print("{YELLOW} FileNotFound:{NOCOLOR} '{cause}'".format(cause=str(cause), **Init.Foreground)) # elif isinstance(cause, NotADirectoryError): # print("{YELLOW} NotADirectory:{NOCOLOR} '{cause}'".format(cause=str(cause), **Init.Foreground)) # elif isinstance(cause, ParserException): # print("{YELLOW} ParserException:{NOCOLOR} {cause}".format(cause=str(cause), **Init.Foreground)) # cause = cause.__cause__ # if (cause is not None): # print("{YELLOW} {name}:{NOCOLOR} {cause}".format(name=cause.__class__.__name__, cause= str(cause), **Init.Foreground)) # # if (not (verbose or debug)): # print() # print("{CYAN} Use '-v' for verbose or '-d' for debug to print out extended messages.{NOCOLOR}".format(**Init.Foreground)) # LineTerminal.exit(1) except ExceptionBase as ex: LineTerminal.printExceptionBase(ex) except NotImplementedError as ex: LineTerminal.printNotImplementedError(ex) #except ImportError as ex: printImportError(ex) except Exception as ex: LineTerminal.printException(ex)