Skip to content

console

The rich console the package prints its output on.

sbmlutils separates output from logging:

  • Output is what a user asked to see: the files create_model writes, the report of a validation with its findings, the summary of a flattening, a download. It is printed on console, the rich console of this module, with colors, tables and links.
  • Logging is for tracing problems and for debugging: a warning about content which is lost or a definition which should be fixed, the error of a libsbml call which failed, and debug detail. It goes to the standard logging module and is configured by the application, see sbmlutils.log.

The console prints to standard output. Silence it for a block of code with quiet, or for the whole program by setting console.quiet = True:

from sbmlutils.console import console, quiet

with quiet():
    create_model(model, filepath="model.xml")

console.quiet = True

Scripts and examples print on the same console, so their output and the output of the package look the same:

from sbmlutils.console import console

console.print(model)
console.rule("Section", style="white")

Importing this module has no side effects on the interpreter. To get rich representations in an interactive session, install them explicitly with rich.pretty.install().

quiet

quiet()

Suppress the output of the package inside the context.

Logging is not affected, warnings and errors are still logged. The console is shared by every thread, so the output of another thread is suppressed as well while the context is active.

Yields:

Type Description
Generator[None]

None

path_text

path_text(path)

Get a path as text which a terminal shows as a link to the file.

Parameters:

Name Type Description Default
path Path | str

the path of a file, relative paths are resolved

required

Returns:

Type Description
Text

the path as it was given, linked to the absolute file URI