rechu.command package

Subpackages

Submodules

rechu.command.alembic module

Subcommand to run Alembic commands for database migration.

class rechu.command.alembic.Alembic[source]

Bases: Base

Run an alembic command.

run() None[source]

Execute the command.

subcommand: str = 'alembic'
subparser_arguments: SubparserArguments = [('args', {'help': 'alembic arguments', 'nargs': '*'})]
subparser_keywords: SubparserKeywords = {'add_help': False, 'help': 'Perform database revision management', 'prefix_chars': '\x00'}

rechu.command.base module

Base for receipt subcommands.

class rechu.command.base.ArgumentKeywords[source]

Bases: Generic[ArgumentT], TypedDict

Keyword arguments acceptable for registering an argument to a subparser of an argument parser.

action: str
choices: Iterable[ArgumentT] | None
const: ArgumentT
default: ArgumentT | str
dest: str | None
help: str | None
metavar: str | tuple[str, ...] | None
nargs: int | str | None
required: bool
type: Callable[[str], ArgumentT] | FileType
class rechu.command.base.Base[source]

Bases: Namespace

Abstract command handling.

classmethod get_command(name: str) Base[source]

Create a command instance for the given subcommand name.

program: str = 'rechu'
classmethod register(name: str) Callable[[type[Base]], type[Base]][source]

Register a subcommand.

classmethod register_arguments() ArgumentParser[source]

Create an argument parser for all registered subcommands.

run() None[source]

Execute the command.

classmethod start(executable: str, argv: Sequence[str]) None[source]

Parse arguments from a sequence of command line arguments and determine which command to run, register any arguments to it and finally execute the action of the command.

subcommand: str = ''
subparser_arguments: Iterable[tuple[str | tuple[str, ...], ArgumentKeywords]] = []
subparser_keywords: SubparserKeywords = {}
class rechu.command.base.SubparserKeywords[source]

Bases: TypedDict

Keyword arguments acceptable for subcommands to register to a subparser of an argument parser.

add_help: bool
aliases: Sequence[str]
allow_abbrev: bool
description: str | None
epilog: str | None
fromfile_prefix_chars: str | None
help: str | None
prefix_chars: str

rechu.command.config module

Subcommand to generate an amalgamate settings file.

class rechu.command.config.Config[source]

Bases: Base

Obtain settings file representation.

run() None[source]

Execute the command.

subcommand: str = 'config'
subparser_arguments: SubparserArguments = [(('section',), {'help': 'Optional table section name to filter on', 'metavar': 'SECTION', 'nargs': '?'}), (('key',), {'help': 'Optional settings key to filter on', 'metavar': 'KEY', 'nargs': '?'}), (('-f', '--file'), {'help': 'Generate based on specific TOML file'}), (('-p', '--prefix'), {'default': (), 'help': 'Section prefixes in specific TOML file to look up', 'nargs': '+'})]
subparser_keywords: SubparserKeywords = {'description': 'Generate settings TOML representation with comments.', 'help': 'Obtain settings representation'}

rechu.command.create module

Database schema creation subcommand.

class rechu.command.create.Create[source]

Bases: Base

Create the database with the database schema.

run() None[source]

Execute the command.

subcommand: str = 'create'
subparser_keywords: SubparserKeywords = {'description': 'Create database schema tables at the configured URI.', 'help': 'Create the database and schema'}

rechu.command.delete module

Subcommand to remove receipt YAML file(s) from data path and database.

class rechu.command.delete.Delete[source]

Bases: Base

Delete YAML files and database entries for receipts.

run() None[source]

Execute the command.

subcommand: str = 'delete'
subparser_arguments: SubparserArguments = [('files', {'help': 'One or more files to delete', 'metavar': 'FILE', 'nargs': '+'}), (('-k', '--keep'), {'action': 'store_true', 'default': False, 'help': 'Do not delete YAML file from data path'})]
subparser_keywords: SubparserKeywords = {'aliases': ['rm'], 'description': 'Delete YAML files for receipts from the data paths and from the database.', 'help': 'Delete receipt files and/or database entries'}

rechu.command.dump module

Subcommand to export database entries as YAML files.

class rechu.command.dump.Dump[source]

Bases: Base

Dump YAML files from the database.

run() None[source]

Execute the command.

subcommand: str = 'dump'
subparser_arguments: SubparserArguments = [('files', {'help': 'One or more product inventories or receipts to write; if no filenames are given, then the entire database is dumped', 'metavar': 'FILE', 'nargs': '*'})]
subparser_keywords: SubparserKeywords = {'description': 'Create one or more YAML files for data in the database.', 'help': 'Export entities from the database'}

rechu.command.match module

Subcommand to match entities in the database.

class rechu.command.match.Match[source]

Bases: Base

Update entities with references to metadata based on matching patterns.

run() None[source]

Execute the command.

subcommand: str = 'match'
subparser_arguments: SubparserArguments = [(('-u', '--update'), {'action': 'store_true', 'default': False, 'help': 'Also update existing matched product references'})]
subparser_keywords: SubparserKeywords = {'description': 'Match products based on labels, prices and discounts and connect the items to their product metadata.', 'help': 'Connect receipt product items to metadata'}

rechu.command.read module

Subcommand to import receipt YAML files.

class rechu.command.read.Read[source]

Bases: Base

Read updated YAML files and import them to the database.

run() None[source]

Execute the command.

subcommand: str = 'read'
subparser_keywords: SubparserKeywords = {'description': 'Find YAML files for products and receipts stored in the data paths and import new or updated entities to the database.', 'help': 'Import updated product and receipt files to the database'}
rechu.command.read.get_updated_time(path: Path) datetime[source]

Retrieve the latest modification time of a file or directory in the path as a datetime object.

Module contents

Subcommand collection package.

class rechu.command.Base[source]

Bases: Namespace

Abstract command handling.

classmethod get_command(name: str) Base[source]

Create a command instance for the given subcommand name.

program: str = 'rechu'
classmethod register(name: str) Callable[[type[Base]], type[Base]][source]

Register a subcommand.

classmethod register_arguments() ArgumentParser[source]

Create an argument parser for all registered subcommands.

run() None[source]

Execute the command.

classmethod start(executable: str, argv: Sequence[str]) None[source]

Parse arguments from a sequence of command line arguments and determine which command to run, register any arguments to it and finally execute the action of the command.

subcommand: str = ''
subparser_arguments: Iterable[tuple[str | tuple[str, ...], ArgumentKeywords]] = []
subparser_keywords: SubparserKeywords = {}