rechu.command.new.step package¶
Submodules¶
rechu.command.new.step.base module¶
Base classes and types for new subcommand steps.
- class rechu.command.new.step.base.DatabaseStep(receipt: Receipt, input: InputSource, database: Database)[source]¶
Bases:
StepA receipt creation step that needs to access the database.
- class rechu.command.new.step.base.Option(*values)[source]¶
Bases:
StrEnumValid input choices to perform specific actions in a step.
- CANCEL = '!'¶
- END = ''¶
- HELP = '?'¶
- STOP = '0'¶
- class rechu.command.new.step.base.ResultMeta(receipt_path: bool = False)[source]¶
Bases:
objectResult of a step being run, indicator additional metadata to update.
receipt_path: Whether to update the receipt path based on receipt metadata
- exception rechu.command.new.step.base.ReturnToMenu(msg: str = '')[source]¶
Bases:
RuntimeErrorIndication that the step is interrupted to return to a menu.
- class rechu.command.new.step.base.Step(receipt: Receipt, input: InputSource)[source]¶
Bases:
objectAbstract base class for a step during receipt creation.
- input: InputSource¶
- abstractmethod run() ResultMeta[source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
rechu.command.new.step.discounts module¶
Discounts step of new subcommand.
- class rechu.command.new.step.discounts.Discounts(receipt: Receipt, input: InputSource, matcher: ProductMatcher, more: bool = False)[source]¶
Bases:
StepStep to add discounts.
- matcher: ProductMatcher¶
- run() ResultMeta[source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
rechu.command.new.step.edit module¶
Edit step of new subcommand.
- class rechu.command.new.step.edit.Edit(receipt: Receipt, input: InputSource, database: Database, matcher: ProductMatcher, editor: str | None = None)[source]¶
Bases:
DatabaseStepStep to edit the receipt in its YAML representation via a temporary file.
- matcher: ProductMatcher¶
- run() ResultMeta[source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
rechu.command.new.step.help module¶
Help step of new subcommand.
- class rechu.command.new.step.help.Help(receipt: Receipt, input: InputSource, menu: dict[str, ~rechu.command.new.step.base.Step]=<factory>)[source]¶
Bases:
StepStep to display help for steps that are usable from the menu.
- run() ResultMeta[source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
rechu.command.new.step.meta module¶
Meta step of new subcommand.
- class rechu.command.new.step.meta.MetaResult(product: Product | None = None, loop: bool = True, key: str | None = None, changed: bool = False, split_range: bool = False)[source]¶
Bases:
objectResult of an attempt to create or edit product metadata or portions of it.
- class rechu.command.new.step.meta.Option(*values)[source]¶
Bases:
StrEnumValid input choices to perform specific actions on product metadata.
- CANCEL = '!'¶
- EDIT = 'edit'¶
- END = ''¶
- HELP = '?'¶
- RANGE = 'range'¶
- SPLIT = 'split'¶
- STOP = '0'¶
- VIEW = 'view'¶
- class rechu.command.new.step.meta.ProductMeta(receipt: Receipt, input: InputSource, database: Database, matcher: ProductMatcher, more: bool = False, products: set[Product] = <factory>, preferred_products: set[Product] = <factory>, preferred_origin: Origin = Origin.DATABASE, _suggestions_loaded: bool = False)[source]¶
Bases:
DatabaseStepStep to add product metadata that matches one or more products.
- add_product(item: ProductItem | None = None, initial_key: str | None = None, matched_items: set[ProductItem] | None = None, product: Product | None = None) MetaResult[source]¶
Request fields for a product’s metadata and add it to the database as well as a products YAML file. item is an optional product item from the receipt to specifically match the metadata for. initial_key is a metadata key to use for the first prompt. matched_items is a set of product items on the receipt that already have metadata. product is an existing product to start with, if any. Returns a MetaResult object indicating whether to attempt to create more product metadata (loop) and the current prompt answer (key).
- get_choice(prompt: str, options: Sequence[Option] = (), hidden_options: Sequence[Option] = (), meta_fields: bool = True) str[source]¶
Obtain a key or metadata editing option by prompting a query and retrieving an input, possibly autocompleting the option.
- matcher: ProductMatcher¶
- run() ResultMeta[source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
rechu.command.new.step.products module¶
Products step of new subcommand.
- class rechu.command.new.step.products.Products(receipt: Receipt, input: InputSource, database: Database, matcher: ProductMatcher)[source]¶
Bases:
DatabaseStepStep to add products.
- add_product(first: bool = False) bool[source]¶
Request fields for a product and add it to the receipt.
- matcher: ProductMatcher¶
- run() ResultMeta[source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
rechu.command.new.step.quit module¶
Quit step of new subcommand.
- class rechu.command.new.step.quit.Quit(receipt: Receipt, input: InputSource)[source]¶
Bases:
StepStep to exit the receipt creation menu.
- run() ResultMeta[source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
rechu.command.new.step.read module¶
Read step of new subcommand.
- class rechu.command.new.step.read.Read(receipt: Receipt, input: InputSource, database: Database, matcher: ProductMatcher)[source]¶
Bases:
DatabaseStepStep to check if there are any new or updated product metadata entries in the file inventory that should be synchronized with the database inventory before creating and matching receipt products.
- matcher: ProductMatcher¶
- run() ResultMeta[source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
rechu.command.new.step.view module¶
View step of new subcommand.
- class rechu.command.new.step.view.View(receipt: Receipt, input: InputSource, database: Database, products: set[Product] | None = None)[source]¶
Bases:
DatabaseStepStep to display the receipt in its YAML representation.
- run() ResultMeta[source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
rechu.command.new.step.write module¶
Write step of new subcommand.
- class rechu.command.new.step.write.Write(receipt: Receipt, input: InputSource, database: Database, matcher: ProductMatcher, _path: Path | None = None)[source]¶
Bases:
DatabaseStepFinal step to write the receipt to a YAML file and store in the database.
- matcher: ProductMatcher¶
- run() ResultMeta[source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
Module contents¶
Steps for creating a receipt in new subcommand.
- class rechu.command.new.step.Discounts(receipt: Receipt, input: InputSource, matcher: ProductMatcher, more: bool = False)[source]¶
Bases:
StepStep to add discounts.
- matcher: ProductMatcher¶
- run() ResultMeta[source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
- class rechu.command.new.step.Edit(receipt: Receipt, input: InputSource, database: Database, matcher: ProductMatcher, editor: str | None = None)[source]¶
Bases:
DatabaseStepStep to edit the receipt in its YAML representation via a temporary file.
- matcher: ProductMatcher¶
- run() ResultMeta[source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
- class rechu.command.new.step.Help(receipt: Receipt, input: InputSource, menu: dict[str, ~rechu.command.new.step.base.Step]=<factory>)[source]¶
Bases:
StepStep to display help for steps that are usable from the menu.
- run() ResultMeta[source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
- class rechu.command.new.step.ProductMeta(receipt: Receipt, input: InputSource, database: Database, matcher: ProductMatcher, more: bool = False, products: set[Product] = <factory>, preferred_products: set[Product] = <factory>, preferred_origin: Origin = Origin.DATABASE, _suggestions_loaded: bool = False)[source]¶
Bases:
DatabaseStepStep to add product metadata that matches one or more products.
- add_product(item: ProductItem | None = None, initial_key: str | None = None, matched_items: set[ProductItem] | None = None, product: Product | None = None) MetaResult[source]¶
Request fields for a product’s metadata and add it to the database as well as a products YAML file. item is an optional product item from the receipt to specifically match the metadata for. initial_key is a metadata key to use for the first prompt. matched_items is a set of product items on the receipt that already have metadata. product is an existing product to start with, if any. Returns a MetaResult object indicating whether to attempt to create more product metadata (loop) and the current prompt answer (key).
- get_choice(prompt: str, options: Sequence[Option] = (), hidden_options: Sequence[Option] = (), meta_fields: bool = True) str[source]¶
Obtain a key or metadata editing option by prompting a query and retrieving an input, possibly autocompleting the option.
- matcher: ProductMatcher¶
- run() ResultMeta[source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
- class rechu.command.new.step.Products(receipt: Receipt, input: InputSource, database: Database, matcher: ProductMatcher)[source]¶
Bases:
DatabaseStepStep to add products.
- add_product(first: bool = False) bool[source]¶
Request fields for a product and add it to the receipt.
- matcher: ProductMatcher¶
- run() ResultMeta[source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
- class rechu.command.new.step.Quit(receipt: Receipt, input: InputSource)[source]¶
Bases:
StepStep to exit the receipt creation menu.
- run() ResultMeta[source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
- class rechu.command.new.step.Read(receipt: Receipt, input: InputSource, database: Database, matcher: ProductMatcher)[source]¶
Bases:
DatabaseStepStep to check if there are any new or updated product metadata entries in the file inventory that should be synchronized with the database inventory before creating and matching receipt products.
- matcher: ProductMatcher¶
- run() ResultMeta[source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
- exception rechu.command.new.step.ReturnToMenu(msg: str = '')[source]¶
Bases:
RuntimeErrorIndication that the step is interrupted to return to a menu.
- class rechu.command.new.step.Step(receipt: Receipt, input: InputSource)[source]¶
Bases:
objectAbstract base class for a step during receipt creation.
- input: InputSource¶
- abstractmethod run() ResultMeta[source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
- class rechu.command.new.step.View(receipt: Receipt, input: InputSource, database: Database, products: set[Product] | None = None)[source]¶
Bases:
DatabaseStepStep to display the receipt in its YAML representation.
- run() ResultMeta[source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.
- class rechu.command.new.step.Write(receipt: Receipt, input: InputSource, database: Database, matcher: ProductMatcher, _path: Path | None = None)[source]¶
Bases:
DatabaseStepFinal step to write the receipt to a YAML file and store in the database.
- matcher: ProductMatcher¶
- run() ResultMeta[source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.