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.ResultMeta[source]¶
Bases:
TypedDictResult of a step being run, indicator additional metadata to update.
‘receipt_path’: Boolean indicating pdate the path of the receipt 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, matcher: ProductMatcher, editor: str | None = None)[source]¶
Bases:
StepStep 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: ~rechu.models.receipt.Receipt, input: ~rechu.command.new.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.ProductMeta(receipt: ~rechu.models.receipt.Receipt, input: ~rechu.command.new.input.InputSource, matcher: ~rechu.matcher.product.ProductMatcher, more: bool = False, products: set[~rechu.models.product.Product] = <factory>, _suggestions_loaded: bool = False)[source]¶
Bases:
StepStep 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) tuple[bool, str | None][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 whether to no longer attempt to create product metadata and the current prompt answer.
- get_choice(prompt: str, options: Sequence[str] = (), hidden_options: Sequence[str] = (), 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, matcher: ProductMatcher)[source]¶
Bases:
StepStep 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, matcher: ProductMatcher)[source]¶
Bases:
StepStep 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, products: set[Product] | None = None)[source]¶
Bases:
StepStep 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, matcher: ProductMatcher, _path: Path | None = None)[source]¶
Bases:
StepFinal 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.
- input: InputSource¶
- 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, matcher: ProductMatcher, editor: str | None = None)[source]¶
Bases:
StepStep to edit the receipt in its YAML representation via a temporary file.
- input: InputSource¶
- 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: ~rechu.models.receipt.Receipt, input: ~rechu.command.new.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.
- input: InputSource¶
- 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: ~rechu.models.receipt.Receipt, input: ~rechu.command.new.input.InputSource, matcher: ~rechu.matcher.product.ProductMatcher, more: bool = False, products: set[~rechu.models.product.Product] = <factory>, _suggestions_loaded: bool = False)[source]¶
Bases:
StepStep 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) tuple[bool, str | None][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 whether to no longer attempt to create product metadata and the current prompt answer.
- get_choice(prompt: str, options: Sequence[str] = (), hidden_options: Sequence[str] = (), 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.
- input: InputSource¶
- 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, matcher: ProductMatcher)[source]¶
Bases:
StepStep to add products.
- add_product(first: bool = False) bool[source]¶
Request fields for a product and add it to the receipt.
- input: InputSource¶
- 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, matcher: ProductMatcher)[source]¶
Bases:
StepStep 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.
- input: InputSource¶
- 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, products: set[Product] | None = None)[source]¶
Bases:
StepStep to display the receipt in its YAML representation.
- input: InputSource¶
- 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, matcher: ProductMatcher, _path: Path | None = None)[source]¶
Bases:
StepFinal step to write the receipt to a YAML file and store in the database.
- input: InputSource¶
- matcher: ProductMatcher¶
- run() ResultMeta[source]¶
Perform the step. Returns whether there is additional metadata which needs to be updated outside of the step.