pyEDAA.Reports.CLI

Tools to extract data from UCDB files.

Usage

First export/convert the Aldec Coverage Database (ACDB) into UCDB (Universal Coverage Database) format. The helper program acdb2xml (part of Active-HDL or Riviera-PRO installation) can be used.

acdb2xml -i aggregate.acdb -o ucdb.xml

At next use this layer’s service program to convert from UCDB to Cobertura format.

pyedaa-ucis export --ucdb ucdb.xml --cobertura cobertura.xml

Submodules

Functions

  • main(): Entrypoint to start program execution.

Classes

  • ProgramBase: Base-class for all program classes.

  • Application: Program class to implement the command line interface (CLI) using commands and options.


Functions

pyEDAA.Reports.CLI.main()[source]

Entrypoint to start program execution.

Return type:

NoReturn

This function should be called either from:
  • if __name__ == "__main__": or

  • console_scripts entry point configured via setuptools in setup.py.

This function creates an instance of Program in a try ... except environment. Any exception caught is formatted and printed before the program returns with a non-zero exit code.


Classes

class pyEDAA.Reports.CLI.ProgramBase(mode=Mode.AllLinearToStdOut)[source]

Base-class for all program classes.

Inheritance

Inheritance diagram of ProgramBase

Parameters:

mode (Mode)

_PrintHeadline()[source]

Print the program’s headline.

Return type:

None

CheckPythonVersion(version)

Check if the used Python interpreter fulfills the minimum version requirements.

Return type:

None

Parameters:

version (Tuple[int, ...])

property Debug: bool

Returns true, if debug messages are enabled.

Exit(returnCode=0)

Exit the terminal application by uninitializing color support and returning an Exit code.

Parameters:

returnCode (int) – Return code for application exit.

Return type:

NoReturn

ExitOnPreviousCriticalWarnings(includeErrors=True)

Exit application if critical warnings have been printed.

Return type:

None

Parameters:

includeErrors (bool)

ExitOnPreviousErrors()

Exit application if errors have been printed.

Return type:

None

ExitOnPreviousWarnings(includeCriticalWarnings=True, includeErrors=True)

Exit application if warnings have been printed.

Return type:

None

Parameters:
  • includeCriticalWarnings (bool)

  • includeErrors (bool)

FATAL_EXIT_CODE: ClassVar[int] = 255

Return code for fatal exits.

FatalExit(returnCode=0)

Exit the terminal application by uninitializing color support and returning a fatal Exit code.

Parameters:

returnCode (int) – Return code for application exit.

Return type:

NoReturn

Foreground = {'BLUE': '\x1b[94m', 'CYAN': '\x1b[96m', 'DARK_BLUE': '\x1b[34m', 'DARK_CYAN': '\x1b[36m', 'DARK_GRAY': '\x1b[90m', 'DARK_GREEN': '\x1b[32m', 'DARK_RED': '\x1b[31m', 'DARK_YELLOW': '\x1b[33m', 'ERROR': '\x1b[91m', 'GRAY': '\x1b[37m', 'GREEN': '\x1b[92m', 'HEADLINE': '\x1b[95m', 'MAGENTA': '\x1b[95m', 'NOCOLOR': '\x1b[39m', 'RED': '\x1b[91m', 'WARNING': '\x1b[93m', 'WHITE': '\x1b[97m', 'YELLOW': '\x1b[93m'}

Terminal colors

classmethod GetMethodsWithAttributes(predicate: TAttr | Iterable[TAttr] | None = None) Dict[Callable, Tuple[Attribute, ...]]
Parameters:

predicate (TypeVar(TAttr) | Iterable[TypeVar(TAttr)] | None)

Return type:

Dict[Callable, Tuple[Attribute, ...]]

Returns:

Raises:
static GetTerminalSize()

Returns the terminal size as tuple (width, height) for Windows, macOS (Darwin), Linux, cygwin (Windows), MinGW32/64 (Windows).

Return type:

Tuple[int, int]

Returns:

A tuple containing width and height of the terminal’s size in characters.

Raises:

PlatformNotSupportedException – When a platform is not yet supported.

property Height: int

Read-only property to access the terminal’s height.

Returns:

The terminal window’s height in characters.

INDENT: ClassVar[str] = '  '

Indentation. Default: "  " (2 spaces)

ISSUE_TRACKER_URL: ClassVar[str] = None

URL to the issue tracker for reporting bugs.

InitializeColors()

Initialize the terminal for color support by colorama.

Return type:

bool

Returns:

True, if ‘colorama’ package could be imported and initialized.

property LogLevel: Severity

Return the current minimal severity level for writing.

NOT_IMPLEMENTED_EXCEPTION_EXIT_CODE: ClassVar[int] = 240

Return code, if unimplemented methods or code sections were called.

PYTHON_VERSION_CHECK_FAILED_EXIT_CODE: ClassVar[int] = 254

Return code, if version check was not successful.

PrintException(ex)

Prints an exception of type Exception and its traceback.

If the exception as a nested action, the cause is printed as well.

If ISSUE_TRACKER_URL is configured, a URL to the issue tracker is added.

Return type:

NoReturn

Parameters:

ex (Exception)

PrintExceptionBase(ex)

Prints an exception of type ExceptionBase and its traceback.

If the exception as a nested action, the cause is printed as well.

If ISSUE_TRACKER_URL is configured, a URL to the issue tracker is added.

Return type:

NoReturn

Parameters:

ex (Exception)

PrintNotImplementedError(ex)

Prints a not-implemented exception of type NotImplementedError.

Return type:

NoReturn

Parameters:

ex (NotImplementedError)

property Quiet: bool

Returns true, if quiet mode is enabled.

UNHANDLED_EXCEPTION_EXIT_CODE: ClassVar[int] = 241

Return code, if an unhandled exception reached the topmost exception handler.

UninitializeColors()

Uninitialize the terminal for color support by colorama.

Return type:

bool

Returns:

True, if ‘colorama’ package could be imported and uninitialized.

property Verbose: bool

Returns true, if verbose messages are enabled.

property Width: int

Read-only property to access the terminal’s width.

Returns:

The terminal window’s width in characters.

WriteLine(line)

Print a formatted line to the underlying terminal/console offered by the operating system.

Return type:

bool

Parameters:

line (Line)

WriteLineToStdErr(message, end='\\n')

Low-level method for writing to STDERR.

Parameters:
  • message (str) – Message to write to STDERR.

  • end (str) – Use newline character. Default: \n.

Return type:

int

Returns:

Number of written characters.

WriteLineToStdOut(message, end='\\n')

Low-level method for writing to STDOUT.

Parameters:
  • message (str) – Message to write to STDOUT.

  • end (str) – Use newline character. Default: \n.

Return type:

int

Returns:

Number of written characters.

WriteNormal(message, indent=0, appendLinebreak=True)

Write a normal message.

Depending on internal settings and rules, a message might be skipped.

Parameters:
  • message (str) – Message to write.

  • indent (int) – Indentation level of the message.

  • appendLinebreak (bool) – Append a linebreak after the message. Default: True

Return type:

bool

Returns:

True, if message was actually written.

WriteToStdErr(message)

Low-level method for writing to STDERR.

Parameters:

message (str) – Message to write to STDERR.

Return type:

int

Returns:

Number of written characters.

WriteToStdOut(message)

Low-level method for writing to STDOUT.

Parameters:

message (str) – Message to write to STDOUT.

Return type:

int

Returns:

Number of written characters.

_LOG_LEVEL_ROUTING__: Dict[Severity, Tuple[Callable[[str, str], int]]]

Message routing rules.

_LOG_MESSAGE_FORMAT__ = {Severity.Debug: '{DARK_GRAY}{message}{NOCOLOR}', Severity.Verbose: '{GRAY}{message}{NOCOLOR}', Severity.DryRun: '{DARK_CYAN}[DRY] {message}{NOCOLOR}', Severity.Normal: '{WHITE}{message}{NOCOLOR}', Severity.Info: '{WHITE}{message}{NOCOLOR}', Severity.Warning: '{YELLOW}[WARNING]  {message}{NOCOLOR}', Severity.Critical: '{DARK_YELLOW}[CRITICAL] {message}{NOCOLOR}', Severity.Quiet: '{WHITE}{message}{NOCOLOR}', Severity.Error: '{RED}[ERROR]    {message}{NOCOLOR}', Severity.Fatal: '{DARK_RED}[FATAL]    {message}{NOCOLOR}'}

Message formatting rules.

_PrintVersion(author, email, copyright, license, version)

Helper method to print the version information.

Parameters:
  • author (str) – Author of the application.

  • email (str) – The author’s email address.

  • copyright (str) – The copyright information.

  • license (str) – The license.

  • version (str) – The application’s version.

Return type:

None

Example usage

def _PrintVersion(self):
  from MyModule import __author__, __email__, __copyright__, __license__, __version__

  super()._PrintVersion(__author__, __email__, __copyright__, __license__, __version__)
__getstate__() Dict[str, Any]

Helper for pickle.

Return type:

Dict[str, Any]

__init__(mode=Mode.AllLinearToStdOut)

Initializer of a line-based terminal interface.

Parameters:

mode (Mode) – Defines what output (normal, error, data) to write where. Default: a linear flow all to STDOUT.

Return type:

None

__new__(**kwargs: Any)
Parameters:
_height: int

Terminal height in characters

_stderr: TextIOWrapper

STDERR

_stdin: TextIOWrapper

STDIN

_stdout: TextIOWrapper

STDOUT

_width: int

Terminal width in characters

class pyEDAA.Reports.CLI.Application[source]

Program class to implement the command line interface (CLI) using commands and options.

Inheritance

Inheritance diagram of Application

ISSUE_TRACKER_URL: ClassVar[str] = 'https://github.com/edaa-org/pyEDAA.Reports/issues'

URL to the issue tracker for reporting bugs.

__init__()[source]

Initializer of a line-based terminal interface.

Parameters:

mode – Defines what output (normal, error, data) to write where. Default: a linear flow all to STDOUT.

Return type:

None

HandleDefault(_)[source]

Handle program calls without any command.

Return type:

None

Parameters:

_ (Namespace)

HandleHelp(args)[source]

Handle program calls with command help.

Return type:

None

Parameters:

args (Namespace)

HandleVersion(_)[source]

Handle program calls with command version.

Return type:

None

Parameters:

_ (Namespace)

_PrintVersion()[source]

Helper function to print the version information.

Return type:

None

_PrintHelp(command=None)[source]

Helper function to print the command line parsers help page(s).

Return type:

None

Parameters:

command (str | None)

CheckPythonVersion(version)

Check if the used Python interpreter fulfills the minimum version requirements.

Return type:

None

Parameters:

version (Tuple[int, ...])

property Debug: bool

Returns true, if debug messages are enabled.

Exit(returnCode=0)

Exit the terminal application by uninitializing color support and returning an Exit code.

Parameters:

returnCode (int) – Return code for application exit.

Return type:

NoReturn

ExitOnPreviousCriticalWarnings(includeErrors=True)

Exit application if critical warnings have been printed.

Return type:

None

Parameters:

includeErrors (bool)

ExitOnPreviousErrors()

Exit application if errors have been printed.

Return type:

None

ExitOnPreviousWarnings(includeCriticalWarnings=True, includeErrors=True)

Exit application if warnings have been printed.

Return type:

None

Parameters:
  • includeCriticalWarnings (bool)

  • includeErrors (bool)

FATAL_EXIT_CODE: ClassVar[int] = 255

Return code for fatal exits.

FatalExit(returnCode=0)

Exit the terminal application by uninitializing color support and returning a fatal Exit code.

Parameters:

returnCode (int) – Return code for application exit.

Return type:

NoReturn

Foreground = {'BLUE': '\x1b[94m', 'CYAN': '\x1b[96m', 'DARK_BLUE': '\x1b[34m', 'DARK_CYAN': '\x1b[36m', 'DARK_GRAY': '\x1b[90m', 'DARK_GREEN': '\x1b[32m', 'DARK_RED': '\x1b[31m', 'DARK_YELLOW': '\x1b[33m', 'ERROR': '\x1b[91m', 'GRAY': '\x1b[37m', 'GREEN': '\x1b[92m', 'HEADLINE': '\x1b[95m', 'MAGENTA': '\x1b[95m', 'NOCOLOR': '\x1b[39m', 'RED': '\x1b[91m', 'WARNING': '\x1b[93m', 'WHITE': '\x1b[97m', 'YELLOW': '\x1b[93m'}

Terminal colors

classmethod GetMethodsWithAttributes(predicate: TAttr | Iterable[TAttr] | None = None) Dict[Callable, Tuple[Attribute, ...]]
Parameters:

predicate (TypeVar(TAttr) | Iterable[TypeVar(TAttr)] | None)

Return type:

Dict[Callable, Tuple[Attribute, ...]]

Returns:

Raises:
static GetTerminalSize()

Returns the terminal size as tuple (width, height) for Windows, macOS (Darwin), Linux, cygwin (Windows), MinGW32/64 (Windows).

Return type:

Tuple[int, int]

Returns:

A tuple containing width and height of the terminal’s size in characters.

Raises:

PlatformNotSupportedException – When a platform is not yet supported.

HandleUnittest(args)

Handle program calls with command unittest.

Return type:

None

Parameters:

args (Namespace)

property Height: int

Read-only property to access the terminal’s height.

Returns:

The terminal window’s height in characters.

INDENT: ClassVar[str] = '  '

Indentation. Default: "  " (2 spaces)

InitializeColors()

Initialize the terminal for color support by colorama.

Return type:

bool

Returns:

True, if ‘colorama’ package could be imported and initialized.

property LogLevel: Severity

Return the current minimal severity level for writing.

property MainParser: ArgumentParser

Returns the main parser.

NOT_IMPLEMENTED_EXCEPTION_EXIT_CODE: ClassVar[int] = 240

Return code, if unimplemented methods or code sections were called.

PYTHON_VERSION_CHECK_FAILED_EXIT_CODE: ClassVar[int] = 254

Return code, if version check was not successful.

PrintException(ex)

Prints an exception of type Exception and its traceback.

If the exception as a nested action, the cause is printed as well.

If ISSUE_TRACKER_URL is configured, a URL to the issue tracker is added.

Return type:

NoReturn

Parameters:

ex (Exception)

PrintExceptionBase(ex)

Prints an exception of type ExceptionBase and its traceback.

If the exception as a nested action, the cause is printed as well.

If ISSUE_TRACKER_URL is configured, a URL to the issue tracker is added.

Return type:

NoReturn

Parameters:

ex (Exception)

PrintNotImplementedError(ex)

Prints a not-implemented exception of type NotImplementedError.

Return type:

NoReturn

Parameters:

ex (NotImplementedError)

property Quiet: bool

Returns true, if quiet mode is enabled.

property SubParsers: Dict

Returns the sub-parsers.

UNHANDLED_EXCEPTION_EXIT_CODE: ClassVar[int] = 241

Return code, if an unhandled exception reached the topmost exception handler.

UninitializeColors()

Uninitialize the terminal for color support by colorama.

Return type:

bool

Returns:

True, if ‘colorama’ package could be imported and uninitialized.

property Verbose: bool

Returns true, if verbose messages are enabled.

property Width: int

Read-only property to access the terminal’s width.

Returns:

The terminal window’s width in characters.

WriteLine(line)

Print a formatted line to the underlying terminal/console offered by the operating system.

Return type:

bool

Parameters:

line (Line)

WriteLineToStdErr(message, end='\\n')

Low-level method for writing to STDERR.

Parameters:
  • message (str) – Message to write to STDERR.

  • end (str) – Use newline character. Default: \n.

Return type:

int

Returns:

Number of written characters.

WriteLineToStdOut(message, end='\\n')

Low-level method for writing to STDOUT.

Parameters:
  • message (str) – Message to write to STDOUT.

  • end (str) – Use newline character. Default: \n.

Return type:

int

Returns:

Number of written characters.

WriteNormal(message, indent=0, appendLinebreak=True)

Write a normal message.

Depending on internal settings and rules, a message might be skipped.

Parameters:
  • message (str) – Message to write.

  • indent (int) – Indentation level of the message.

  • appendLinebreak (bool) – Append a linebreak after the message. Default: True

Return type:

bool

Returns:

True, if message was actually written.

WriteToStdErr(message)

Low-level method for writing to STDERR.

Parameters:

message (str) – Message to write to STDERR.

Return type:

int

Returns:

Number of written characters.

WriteToStdOut(message)

Low-level method for writing to STDOUT.

Parameters:

message (str) – Message to write to STDOUT.

Return type:

int

Returns:

Number of written characters.

_LOG_LEVEL_ROUTING__: Dict[Severity, Tuple[Callable[[str, str], int]]]

Message routing rules.

_LOG_MESSAGE_FORMAT__ = {Severity.Debug: '{DARK_GRAY}{message}{NOCOLOR}', Severity.Verbose: '{GRAY}{message}{NOCOLOR}', Severity.DryRun: '{DARK_CYAN}[DRY] {message}{NOCOLOR}', Severity.Normal: '{WHITE}{message}{NOCOLOR}', Severity.Info: '{WHITE}{message}{NOCOLOR}', Severity.Warning: '{YELLOW}[WARNING]  {message}{NOCOLOR}', Severity.Critical: '{DARK_YELLOW}[CRITICAL] {message}{NOCOLOR}', Severity.Quiet: '{WHITE}{message}{NOCOLOR}', Severity.Error: '{RED}[ERROR]    {message}{NOCOLOR}', Severity.Fatal: '{DARK_RED}[FATAL]    {message}{NOCOLOR}'}

Message formatting rules.

_PrintHeadline()

Print the program’s headline.

Return type:

None

__getstate__() Dict[str, Any]

Helper for pickle.

Return type:

Dict[str, Any]

__new__(**kwargs: Any)
Parameters:
_height: int

Terminal height in characters

_stderr: TextIOWrapper

STDERR

_stdin: TextIOWrapper

STDIN

_stdout: TextIOWrapper

STDOUT

_width: int

Terminal width in characters