Skip to main content

Python Parser for Cooklang

Project description

cooklang-py

Tests Format and Lint CodeQL

A parser for the Cooklang recipe markup language

Installation

To install just run:

pip install cooklang-py

Documentation

Full documentation is available at https://cooklang-py.readthedocs.io/

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 needed
  • notes - any notes for the item (i.e. "greased", "peeled and diced", etc.)
    • Timings do 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cooklang_py-0.3.2.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cooklang_py-0.3.2-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file cooklang_py-0.3.2.tar.gz.

File metadata

  • Download URL: cooklang_py-0.3.2.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cooklang_py-0.3.2.tar.gz
Algorithm Hash digest
SHA256 90004050ba015aa9f6b4fa5cd94b629816fb0b055c0830eff19de10c8d6c23ba
MD5 b181135afdc58bbf7bc81fdd75abb0fc
BLAKE2b-256 7a31a6024d7e09cbab756ee0bd823549baf054758aec5a9d36957ba49071813d

See more details on using hashes here.

Provenance

The following attestation bundles were made for cooklang_py-0.3.2.tar.gz:

Publisher: publish.yml on brass75/cooklang-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cooklang_py-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: cooklang_py-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cooklang_py-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 770f888a73c599cbf1b9d9aaed8312f161dcfe3bce3558458464829a918f3bfb
MD5 23b42bd8eca749a0cf614de44977ddfb
BLAKE2b-256 c14dc7f4a1a70a5331bb38cd322b7bd4e46507cf60cc35c6beaf6574f28bd441

See more details on using hashes here.

Provenance

The following attestation bundles were made for cooklang_py-0.3.2-py3-none-any.whl:

Publisher: publish.yml on brass75/cooklang-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page