file_output#

Abstract base class for subcommands that output to a file (or stdout).

class FileOutputSubcommand(parser: ArgumentParser)[source]#

Abstract subcommand to output applications as some type of file.

classmethod files_arg(output_type_name: str) → Arg[source]#

Returns a positional arg for files to specify file inputs to the command.

Subclasses should include this to their class args.

Example

class Foo(FileOutputSubcommand):

    args = (

        FileOutputSubcommand.files_arg("FOO"),

        # more args for Foo

    ) + FileOutputSubcommand.other_args()
classmethod other_args() → Args[source]#

Return args for -o / --output to specify where output should be written, and for a --args to pass on any additional command line args to the subcommand.

Subclasses should append these to their class args.

Example

class Foo(FileOutputSubcommand):

    args = (

        FileOutputSubcommand.files_arg("FOO"),

        # more args for Foo

    ) + FileOutputSubcommand.other_args()
after_write_file(args: Namespace, filename: str, doc: Document) → None[source]#
abstractmethod file_contents(args: Namespace, doc: Document) → str | bytes | list[str] | list[bytes][source]#

Subclasses must override this method to return the contents of the output file for the given doc. subclassed methods return different types: str: html, json bytes: SVG, png

Raises:

NotImplementedError –

filename_from_route(route: str, ext: str) → str[source]#
invoke(args: Namespace) → None[source]#
write_file(args: Namespace, filename: str, doc: Document) → None[source]#