Skip to main content

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

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
    • For Ingredient quantity defaults to "some" if it is not set.
    • For Cookware quantity defaults to 1 if it is not set.
  • notes - any notes for the item (i.e. "greased", "peeled and diced", etc.)
    • Timings do not have notes per the Cooklang specification.

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 (with the exception of test cases with Unicode characters.)

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.1.0.tar.gz (5.7 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.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cooklang_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1863669b6a009c65dc366d81fdba3487b6ba78dd070e3e0ef49a7999c633515d
MD5 bfcf7bbecd7bb3a0d4d146c1564b80f1
BLAKE2b-256 73b6bd4ac643915411c2417aee58af29dbe023d785fe70a743fa9572c23d63de

See more details on using hashes here.

Provenance

The following attestation bundles were made for cooklang_py-0.1.0.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.1.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for cooklang_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5d3ca54a40fc0d066ae9b2fccecc4c53f783fa4b954767059e04711f66c3159d
MD5 4ba76dc3431c3c64104915c47cf78c1a
BLAKE2b-256 01ecbe4cd6d312058092fdb329ebdab74f44660920f20ed448443b9fe9ef58ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for cooklang_py-0.1.0-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