Usage
Installation
Install it using pip:
$ pip install tosclib
Working with .tosc files
We want to load an .tosc file first, then we can handle it with tosclib. You can import xml.etree.ElementTree too.
- tosclib.tosc.load(inputPath: Optional[str] = None) xml.etree.ElementTree.Element
Reads .tosc file as bytes and returns the xml root element
- Parameters
inputPath – the path to the .tosc file, defaults to None
Our main class is ElementTOSC, which is designed to address the basic structure of Touch OSC objects.
- class tosclib.tosc.ElementTOSC(e: xml.etree.ElementTree.Element)
Example:
from tosclib import tosc
root = tosc.load(args.Input)
parent = tosc.ElementTOSC(root[0])
parent.createProperty(
type = "s",
key = "Username",
text = "Geoff")
print("Added Property: ")
parent.showProperty(args.Property)
tosc.write(root, args.Output)