Python Parser for Cooklang
Project description
cooklang-py
A parser for the Cooklang recipe markup language
Installation
To install just run:
pip install cooklang-py
Documentation
Full documentation is available at docs/docs/index.md
Recipe
The Recipe is the primary unit. There are 2 ways to create a Recipe object:
from cooklang_py import Recipe
# Create from a string in memory
recipe_string = '<your recipe here>'
recipe = Recipe(recipe_string)
# Create from a file
recipe_file = '/path/to/recipe/file'
recipe = Recipe.from_file(recipe_file)
Just like a recipe in a book a Recipe contains:
- Ingredients
- Cookware / equipment
- Timings
- Metadata (servings, cook time, etc.)
To see how to define these in your input please refer to the Cooklang language specification
When the recipe is parsed there will be a list of Step objects. Each step object can contain:
- Ingredients
- Cookware
- Timings
- Instructions (text)
At both the Recipe and Step level you can access the list of Ingredients and Cookware
for the recipe or step.
Cookware, Timings, and Ingredients
Cookware, timings, and ingredients are the backbone of the recipe. In this package all three
inherit from the BaseObj. They all have the following 3 attributes:
name- the name of the item (i.e. pot, carrot, etc.)quantity- how much is needednotes- any notes for the item (i.e. "greased", "peeled and diced", etc.)Timingsdo not have notes per the Cooklang specification.
Overriding implementations
The implementations of Cookware, Timings, and Ingredients can be overridden by creating a new
implementation (inheriting from either that class or from BaseObj) and calling Recipe or
Step with an updated prefixes dictionary that points the desired prefix to the new class.
Compatibility
cooklang-py passes all canonical tests defined at
https://github.com/cooklang/cooklang-rs/blob/main/tests/canonical.yaml
for the following platforms:
- Linux
- MacOS
- Windows
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cooklang_py-0.3.0.tar.gz.
File metadata
- Download URL: cooklang_py-0.3.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4d7da56ee7a42d75346482a423ed1e854ac7c76e00eb956dae17827965a6d21
|
|
| MD5 |
492014fe09b7c198438ae4fb90dca4ff
|
|
| BLAKE2b-256 |
d11683f59797cfa6f01f5c8a61734a6e94e531ab29998b843582b7d7ef941ff6
|
Provenance
The following attestation bundles were made for cooklang_py-0.3.0.tar.gz:
Publisher:
publish.yml on brass75/cooklang-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cooklang_py-0.3.0.tar.gz -
Subject digest:
f4d7da56ee7a42d75346482a423ed1e854ac7c76e00eb956dae17827965a6d21 - Sigstore transparency entry: 275541760
- Sigstore integration time:
-
Permalink:
brass75/cooklang-py@9323299a117a13a10260023f4b88ef33ad0827a2 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/brass75
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9323299a117a13a10260023f4b88ef33ad0827a2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file cooklang_py-0.3.0-py3-none-any.whl.
File metadata
- Download URL: cooklang_py-0.3.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7152cf745c12af29275a086c479bb29e70d55f6d2da15547767dcbf00b2984cd
|
|
| MD5 |
ca8353f57b0fb616d43596be18a3201e
|
|
| BLAKE2b-256 |
a0fd68ab55f912bb20bdde08295567ae0c2d7977d89a72d233761afb35fc6db1
|
Provenance
The following attestation bundles were made for cooklang_py-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on brass75/cooklang-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cooklang_py-0.3.0-py3-none-any.whl -
Subject digest:
7152cf745c12af29275a086c479bb29e70d55f6d2da15547767dcbf00b2984cd - Sigstore transparency entry: 275541771
- Sigstore integration time:
-
Permalink:
brass75/cooklang-py@9323299a117a13a10260023f4b88ef33ad0827a2 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/brass75
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9323299a117a13a10260023f4b88ef33ad0827a2 -
Trigger Event:
release
-
Statement type: