Skip to main content

General Device Type Format (GDTF) library for Python

Project description

python-gdtf

Python library for General Device Type Format

GDTF specification as per https://gdtf.eu/gdtf/prologue/introduction/

See source code for documentation. Naming conventions, in general, are identical to that on the GDTF, CamelCase is replaced with underscore_delimiters.

Credits

Originally created by Jack Page. Friendly forked to Open-Stage by vanous. We continue publishing to pypi under the same pygdtf name with Jack's permission.

Used for example by BlenderDMX.

Source code

PyPi page

Pytest

Check links in markdown

Important changes

Version 1.1.0

⚠️ List of DMX Channels provided by dmx_mode.dmx_channels is now a complete list of all DMX channels calculated by obtaining DMX channels for geometries, Geometry References and so on, no need to use the .utils methods anymore.

⚠️ The list of channels as dictionaries can be obtained by dmx_mode.dmx_channels.as_dicts(), the "id" has been renamed to "attribute". DMX Channel now contains Logical Channels and then Channel Functions.

⚠️ Many of the .utils package methods have been moved directly to the main part of pygdtf. External usage of methods from .util should not be needed anymore.

.utils.get_dmx_modes_info

modes_info = []

for idx, mode in enumerate(gdtf_fixture.dmx_modes):
    dmx_mode_info = {
        "mode_id": idx,
        "mode_name": mode.name,
        "mode_dmx_channel_count": mode.dmx_channels_count,
        "mode_virtual_channel_count": mode.virtual_channels_count,
        "mode_dmx_breaks_count": mode.dmx_breaks_count,
        "mode_dmx_channels": mode.dmx_channels.as_dicts(),
        "mode_virtual_channels": mode.virtual_channels.as_dicts(),
    }
    modes_info.append(dmx_mode_info)

Getting channels

  • as channels, flattened: fixture.dmx_modes[0].dmx_channels
  • as channels, by breaks: fixture.dmx_modes[0].dmx_channels.by_breaks()
  • as dicts, by breaks: fixture.dmx_modes[0].dmx_channels.as_dicts()
  • as dicts, flattened: fixture.dmx_modes[0].dmx_channels.as_dicts().flattened()

Installation

pip install pygdtf

To install latest version from this git repository, run pip:

python -m pip install https://codeload.github.com/open-stage/python-gdtf/zip/refs/heads/master

Usage

# import
import pygdtf

# parse a GDTF file
gdtf_fixture = pygdtf.FixtureType("BlenderDMX@LED_PAR_64_RGBW@v0.3.gdtf")

# one can also parse just a description.xml file during development or testing
gdtf_fixture = pygdtf.FixtureType(dsc_file="description.xml")

# now access things like DMX modes, channels and so on
# get DMX Mode name
gdtf_fixture.dmx_modes[0].name
'Mode 1 - Standard 16 - bit'

# get number of DMX channels
gdtf_fixture.dmx_modes[0].dmx_channels_count
39

# get number of Virtual channels
gdtf_fixture.dmx_modes[0].virtual_channels_count
0

# get number of DMX breaks
gdtf_fixture.dmx_modes[0].dmx_breaks_count
1

# get DMX channels as objects gdtf_fixture.dmx_modes[0].dmx_channels
<pygdtf.DmxChannel object at 0x7f789c63bb60>, <pygdtf.DmxChannel object at
0x7f789c375590>, <pygdtf.DmxChannel object at 0x7f789c375a90>,...

# get DMX channels as dict
gdtf_fixture.dmx_modes[0].dmx_channels.as_dicts()

[[{'dmx': 1, 'offset': [1, 2], 'id': 'Pan', 'default': 128, 'highlight': None,
'geometry': 'Yoke', 'break': 1, 'parent_name': 'Base', 'channel_functions':
[{'name': 'Pan', 'attribute': 'Pan', 'dmx_from': 0, 'dmx_to': 255, 'default':
128, 'real_fade': 1.833, 'physical_to': 270.0, 'physical_from': -270.0,
'channel_sets': ['', 'Center', '']}, ...

# see the source code for more methods

See BlenderDMX and tests for reference implementation and usage examples.

Usage principles

  • do not use geometry names for anything related to function of the geometry (yoke, pan, tilt, head), use attached GDTF attributes ("Pan", "Tilt") to know what functions should the geometry perform

Status

  • Many GDTF 1.2 features have been implemented
  • Some GDTF 1.1 features have been kept in

Development

PRs appreciated. You can use uv to get the project setup by running:

uv sync

Typing

  • We try to type the main library as well as the utils module, to test run:
mypy pygdtf/**py  --pretty

Format

Testing

  • to test, run: pytest
  • to test typing with mypy run pytest:
pytest --mypy -m mypy pygdtf/**py

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

pygdtf-1.0.6.dev22-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file pygdtf-1.0.6.dev22-py3-none-any.whl.

File metadata

File hashes

Hashes for pygdtf-1.0.6.dev22-py3-none-any.whl
Algorithm Hash digest
SHA256 840c1ef11a6a6e6824daa0d5fe37a9f77b6c73f4b88952578b4e0c6fae3a2768
MD5 95fbbd71c26623c80b1c4bbc1a8a605f
BLAKE2b-256 ed82b7b4590a1cc3c7e08649f12b298b36f36552ff3c4f8282169f33c0952ff1

See more details on using hashes here.

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