Skip to main content

LE Utils

The le-utils package contains shared constants used by Ricecooker, Kolibri, and Kolibri Studio. This package is not meant to be installed or used directly, but plays an important role in all Learning Equality products.

How can I contribute?

We welcome contributors!

To find out how to contribute, visit Contributing to our open code base.

Constants

The Python files in the le_utils/constants/ are used to define constants (usually in ALL_CAPS form) to be used from Python code. The same constants and naming conventions are also provided in JSON format in the folder le_utils/resources/ for use in frontend code. This means, adding a new constant may require editing multiple files: the Python constant-defining file, the JSON-file, and any associated tests.

Languages

The file le_utils/constants/languages.py and the lookup table in le_utils/resources/languagelookup.json define the internal representation for languages codes used by Ricecooker, Kolibri, and Kolibri Studio to identify educational content in different languages.

The internal representation uses a mixture of two-letter codes (e.g. en), two-letter-and-country code (e.g. pt-BR for Brazilian Portuguese), and three-letter codes (e.g., zul for Zulu).

In order to make sure you have the correct language code when interfacing with the Kolibri ecosystem (e.g. when uploading new content to Kolibri Studio), you must lookup the language object using the helper method getlang:

>>> from le_utils.constants.languages import getlang
>>> language_obj = getlang('en')       # lookup language using language code
>>> language_obj
Language(native_name='English', primary_code='en', subcode=None, name='English', ka_name=None)

The function getlang will return None if the lookup fails. In such cases, you can try lookup by name or lookup by alpha2 code (ISO_639-1) methods defined below.

Once you've successfully looked up the language object, you can obtain the internal representation language code from the language object's code attribute:

>>> language_obj.code
'en'

The Ricecooker API expects these internal representation language codes will be supplied for all language attributes (channel language, node language, and files language).

More lookup helper methods

The helper method getlang_by_name allows you to lookup a language by name:

>>> from le_utils.constants.languages import getlang_by_name
>>> language_obj = getlang_by_name('English')  # lookup language by name
>>> language_obj
Language(native_name='English', primary_code='en', subcode=None, name='English', ka_name=None)

The module le_utils.constants.languages defines two other language lookup methods:

  • Use getlang_by_native_name for lookup up names by native language name, e.g., you look for 'Français' to find French.
  • Use getlang_by_alpha2 to perform lookups using the standard two-letter codes defined in ISO_639-1 that are supported by the pycountries library.

The following websites are useful for researching language codes:

Licenses

All content nodes within Kolibri and Kolibri Studio must have a license. The file le_utils/constants/licenses.py contains the constants used to identify the license types. These constants are meant to be used in conjunction with the helper method ricecooker.classes.licenses.get_license to create Licence objects.

To initialize a license object, you must specify the license type and the copyright_holder (str) which identifies a person or an organization. For example:

from ricecooker.classes.licenses import get_license
from le_utils.constants import licenses
license = get_license(licenses.CC_BY, copyright_holder="Khan Academy")

Note: The copyright_holder field is required for all License types except for the public domain license for which copyright_holder can be None.

Content kinds (ContentNode subclasses)

Content items throughout the Kolibri ecosystem come in several kinds. The kind attribute of each object can be one of ("topic", "video", "audio", "exercise" "document", or "html5". See constants/content_kinds.py for latest list.

The currently supported content kinds are:

  • Topic node (folder)
  • Video content nodes backed by a video files and subtitles
  • Audio content nodes backed by an audio files
  • Document content nodes backed by a document files (PDF or ePub)
  • HTML5 app content nodes backed by a HTML5 zip files
  • Slideshow content nodes
  • Exercise content nodes

The kind attribute identifies a subclass of the base content node class within the data model, which differs on Ricecooker, Studio, and Kolibri:

For a detailed description of the common and different model attributes available on content nodes in each part of the platform see this doc.

File formats (extensions)

These are low-level constant that represents what type of file and are essentially synonymous with file extensions. The file format MP4 is simply a convenient proxy for the file extension mp4. See file_formats.py and resourcces/formatlookup.json.

Format presets (ContentNode-File relation)

Every ContentNode is associated with one or more File objects and nature of this association is represented though the format_preset attribute of the file. The format_preset is the role the file is playing in the content node, e.g., thumbnail, high resolution video, or low resolution video. Note that format presets are represented redundantly as python string in constants/format_presets.py and as json resources/presetlookup.json.

You can think of the different format presets on a content node as different "slots" to be filled in by files, with certain slots being required while other optional. For examples, for a VideoNode (kind=video) to be a valid content node, it must have at least one video file associated with it filling either the high_res_video slot or the low_res_video slot. Certain slots can have multiple files in them, like the video_subtitle preset, since a VideoNode can have multiple subtitles associated with it for different languages.

The figure below illustrates the structure between content nodes, files, and format presets.

Illustration of the relationships between content kinds (nodes), files, and format presets.

In the Sample shown, the Video Node is of content kind video and has three files associated with it:

  • The first file has file format mp4 and format preset high_res_video
  • The second file is also in mp4 format but the relation to the content node is that low_res_video
  • A third file with format vtt is associated with the content node with a format preset of video_subtitle.

Format presets play a crucial role throughout the Kolibri content ecosystem and govern such things as content validation rules applied by Ricecooker, Kolibri Studio edit rules, and the rendering logic on Kolibri.

File types (ricecooker.files.File subclasses)

Used on Ricecooker as identifiers to represents what type of file when serializing things to JSON as part of the content import process. Note that file types constants are internal to ricecooker operations and are not used in Kolibri Studio or Kolibri.

Exercises

The file le_utils/constants/exercises.py contains identifiers for different question types and mastery models.

Proquint Channel Tokens

The file le_utils/proquint.py contains helper methods for generating proquint identifiers for content channels. These are short strings that are easy to enter on devices without a full keyboard, e.g. sutul-hakuh.

Archive contents hash

le_utils/archive.py provides contents_sha256, a hash of a zip archive's member paths and bytes that ignores compression and metadata. It identifies files in file_formats.ARCHIVE_FORMATS. Its definition is frozen: ricecooker and Studio index archives by it.

Roles

The role constants are used for Role-based access control (RBAC) within the Kolibri platform. Currently, only two levels of visibility are supported:

  • learner (default): content nodes are visible to all Kolibri users
  • coach: content nodes are only visible to Kolibri coaches and administrators

Metadata labels

These are encoded in spec/labels-v*.json. Once a spec has been finalized it will be added to finalized_specs.yml to ensure that CI will fail any future modifications to this specification. This ensures that the resulting built code has consistent ordering so that generated bits for bitmasks are stable across releases. We also require that all names in the specs be globally unique to minimize confusion and reduce the chance of collisions in translations of these terms for users.

Release files for le-utils 0.2.19

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for le-utils 0.2.19
File Size Uploaded
le_utils-0.2.19.tar.gz 148.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for le-utils 0.2.19
File Interpreter ABI Platform
le_utils-0.2.19-py3-none-any.whl Python 3 none any Details

Total release size: 190.9 kB

Release files / le_utils-0.2.19.tar.gz

Download URL le_utils-0.2.19.tar.gz
Size 148.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a37c9a2930cc93db98ce6639165799065bb170c1e5962697ddd9c2cabfe9b697
BLAKE2b-256 checksum
How to use checksums
d509df69d1c0d8c089c161fce917a5e95569d143b4b8f13ecf7a1368ffa6c808
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / le_utils-0.2.19-py3-none-any.whl

Download URL le_utils-0.2.19-py3-none-any.whl
Size 42.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
11d3843fe59e8dead2213236bfe3dad3a2a5170e17366ec18c50376784f941bc
BLAKE2b-256 checksum
How to use checksums
d5ad0b1f43d030595f1234fc5d91851c463684686c679ae0eef6f7c1d8a9a820
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.19 This release

2 release files

0.2.17

2 release files

0.2.16

1 release file

0.2.15

1 release file

0.2.14

1 release file

0.2.13

1 release file

0.2.12

1 release file

0.2.11

1 release file

0.2.10

1 release file

0.2.9

1 release file

0.2.8

1 release file

0.2.7

1 release file

0.2.6

1 release file

0.2.5

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.42

1 release file

0.1.41

1 release file

0.1.40

1 release file

0.1.39

1 release file

0.1.38

1 release file

0.1.37

1 release file

0.1.36

1 release file

0.1.35

1 release file

0.1.34

1 release file

0.1.30

2 release files

0.1.29

2 release files

0.1.28

2 release files

0.1.27

2 release files

0.1.26

1 release file

0.1.25

1 release file

0.1.24

1 release file

0.1.23

1 release file

0.1.22

1 release file

0.1.21

1 release file

0.1.20

1 release file

0.1.19

1 release file

0.1.18

1 release file

0.1.17

1 release file

0.1.16

1 release file

0.1.15

1 release file

0.1.14

1 release file

0.1.13

1 release file

0.1.12

1 release file

0.1.11

1 release file

0.1.10

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.12

1 release file

0.0.11

1 release file

0.0.10

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page