Skip to main content

My Virtual Rig (MVR) library for Python

Project description

python-mvr

Python library for MVR (My Virtual Rig). MVR is part of GDTF (General Device Type Format)

MVR specification as per https://gdtf.eu/mvr/prologue/introduction/

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

Source code

PyPi page

Pytest

Check links in markdown

Installation

pip install pymvr

To install latest version from git via pip:

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

Usage

Reading

import pymvr
mvr_file = pymvr.GeneralSceneDescription("mvr_file.mvr")

for layer_index, layer in enumerate(mvr_file.scene.layers):
    ... #process data

Writing

import pymvr
from pathlib import Path

# 1. Create a writer instance
mvr_writer = pymvr.GeneralSceneDescriptionWriter()

# 2. Build the MVR object tree
# Create a scene object
scene_obj = pymvr.Scene()

# Create layers and add them to the scene
layers = pymvr.Layers()
scene_obj.layers = layers

# Create a layer and add it to the layers
layer = pymvr.Layer(name="Test layer")
layers.append(layer)

# Create a child list for the layer
child_list = pymvr.ChildList()
layer.child_list = child_list

# Create a fixture and add it to the child list
# Note: A valid fixture would require more attributes
fixture = pymvr.Fixture(name="Test Fixture")
child_list.fixtures.append(fixture)

# 3. Serialize the scene object into the writer's XML root
scene_obj.to_xml(parent=mvr_writer.xml_root)

# 4. Add any necessary files (like GDTF) to the MVR archive
# (This example fixture doesn't have a GDTF file, so this list will be empty)
files_to_pack = []
if fixture.gdtf_spec:
    # The list should contain tuples of (source_path, archive_name)
    files_to_pack.append((fixture.gdtf_spec, fixture.gdtf_spec))
mvr_writer.files_list = list(set(files_to_pack))

# 5. Write the MVR file
output_path = Path("example.mvr")
mvr_writer.write_mvr(output_path)

print(f"MVR file written to {output_path.resolve()}")

See BlenderDMX and tests for reference implementation.

Status

  • Reading and Writing of all aspects of MVR should be covered.

Development

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

uv sync

Typing

  • We try to type the main library, at this point, the --no-strict-optional is needed for mypy tests to pass:
mypy pymvr/*py  --pretty  --no-strict-optional

Format

Testing

  • to test, use pytest
pytest
  • to test typing with mypy use:
pytest --mypy -m mypy pymvr/*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.

pymvr-1.0.0.dev0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file pymvr-1.0.0.dev0-py3-none-any.whl.

File metadata

  • Download URL: pymvr-1.0.0.dev0-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.0

File hashes

Hashes for pymvr-1.0.0.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 52aebb0a875b344414c378b8c8c8699ef4700bd86cc211be240d060d7a1c682c
MD5 be50838b4ed1663a51a933c4d90f4767
BLAKE2b-256 104bfffdb6e906218fc6f644d5430cdcec61f4654a6814f4f4f38e6a27cf3691

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