diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..f6c05b8 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,37 @@ +# The MIT License (MIT) +# +# Copyright (C) 2025 vanous +# +# This file is part of pymvr. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the “Software”), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: trailing-whitespace + - id: check-added-large-files + - id: debug-statements +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.12.5 + hooks: + - id: ruff-format diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f9a336..477f976 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ ### 1.0.0-dev0 -* Breaking changes! +* Breaking changes. There is now an additional .scene object, plus several + other collector objects. Look at the tests/readme for details. * Big refactor of structure - ensure that XML structure is followed in code * Implemented all MVR fields * Big refactor for export diff --git a/README.md b/README.md index 29d47bb..901eecb 100644 --- a/README.md +++ b/README.md @@ -143,30 +143,32 @@ project setup by running: uv sync ``` -### Typing +### Format -- We try to type the main library, at this point, the - `--no-strict-optional` is needed for mypy tests to pass: +- To format, use [ruff](https://docs.astral.sh/ruff/) ```bash -mypy pymvr/*py --pretty --no-strict-optional +uv run ruff format pymvr/* ``` -### Format +### Pre-commit hooks + +- You can use the pre-commit hooks -- To format, use [black](https://github.com/psf/black) or - [ruff](https://docs.astral.sh/ruff/) +```bash +uv run pre-commit install +``` ### Testing - to test, use pytest ```bash -pytest +uv run pytest ``` - to test typing with mypy use: ```bash -pytest --mypy -m mypy pymvr/*py +uv run pytest --mypy -m mypy pymvr/*py ``` diff --git a/RELEASE.md b/RELEASE.md index 97c5785..66355dd 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -5,6 +5,11 @@ * push to master (via PR) * `git tag versionCode` * `git push origin versionCode` +* License headers: +* Make sure to install/update hawkeye +* `cargo install hawkeye` +* Update headers: +* `hawkeye format` * generate wheel with pip wheel: diff --git a/conftest.py b/conftest.py index d2bd7d9..4a2340f 100644 --- a/conftest.py +++ b/conftest.py @@ -1,3 +1,27 @@ +# The MIT License (MIT) +# +# Copyright (C) 2023 vanous +# +# This file is part of pymvr. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the “Software”), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + from pathlib import Path import pytest import pymvr @@ -10,7 +34,9 @@ @pytest.fixture(scope="function") def mvr_scene(request): file_name = request.param[0] - test_mvr_scene_path = Path(Path(__file__).parents[0], "tests", file_name) # test file path is made from current directory, tests directory and a file name + test_mvr_scene_path = Path( + Path(__file__).parents[0], "tests", file_name + ) # test file path is made from current directory, tests directory and a file name mvr_scene = pymvr.GeneralSceneDescription(test_mvr_scene_path) yield mvr_scene @@ -26,4 +52,6 @@ def pytest_configure(config): def pytest_addoption(parser): - parser.addoption("--file-path", action="store", default=None, help="Path to the input file") + parser.addoption( + "--file-path", action="store", default=None, help="Path to the input file" + ) diff --git a/licenserc.toml b/licenserc.toml new file mode 100644 index 0000000..b9096ab --- /dev/null +++ b/licenserc.toml @@ -0,0 +1,38 @@ +# The MIT License (MIT) +# +# Copyright (C) none +# +# This file is part of pymvr. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the “Software”), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +headerPath = "mit-header.txt" + +excludes = [ + ".github/", +] + +[git] +attrs = 'auto' +ignore = 'auto' + +[properties] +inceptionYear = 2023 +projectName = "pymvr" + diff --git a/mit-header.txt b/mit-header.txt new file mode 100644 index 0000000..6cc694f --- /dev/null +++ b/mit-header.txt @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (C) {{attrs.git_file_created_year}} {{ attrs.git_authors | join(", ") }} + +This file is part of {{props["projectName"]}}. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/pymvr/__init__.py b/pymvr/__init__.py index a181e1a..cb8ec3f 100644 --- a/pymvr/__init__.py +++ b/pymvr/__init__.py @@ -1,3 +1,27 @@ +# The MIT License (MIT) +# +# Copyright (C) 2023 vanous +# +# This file is part of pymvr. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the “Software”), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + from typing import List, Union from xml.etree import ElementTree from xml.etree.ElementTree import Element @@ -67,14 +91,20 @@ def __init__(self): self.provider_version: str = __version__ self.files_list: List[str] = [] self.xml_root = ElementTree.Element( - "GeneralSceneDescription", verMajor=self.version_major, verMinor=self.version_minor, provider=self.provider, provider_version=self.provider_version + "GeneralSceneDescription", + verMajor=self.version_major, + verMinor=self.version_minor, + provider=self.provider, + provider_version=self.provider_version, ) def write_mvr(self, path=None): if path is not None: if sys.version_info >= (3, 9): ElementTree.indent(self.xml_root, space=" ", level=0) - xmlstr = ElementTree.tostring(self.xml_root, encoding="unicode", xml_declaration=True) + xmlstr = ElementTree.tostring( + self.xml_root, encoding="unicode", xml_declaration=True + ) with zipfile.ZipFile(path, "w", zipfile.ZIP_DEFLATED) as z: z.writestr("GeneralSceneDescription.xml", xmlstr) for file_path, file_name in self.files_list: @@ -146,7 +176,9 @@ def _read_xml(self, xml_node: "Element"): class CustomCommands(ContainerNode): def _read_xml(self, xml_node: "Element"): - self.children = [CustomCommand(xml_node=i) for i in xml_node.findall("CustomCommand")] + self.children = [ + CustomCommand(xml_node=i) for i in xml_node.findall("CustomCommand") + ] class Overwrites(ContainerNode): @@ -414,7 +446,9 @@ def __init__( self.cast_shadow = cast_shadow self.addresses = addresses if addresses is not None else Addresses() self.alignments = alignments if alignments is not None else Alignments() - self.custom_commands = custom_commands if custom_commands is not None else CustomCommands() + self.custom_commands = ( + custom_commands if custom_commands is not None else CustomCommands() + ) self.overwrites = overwrites if overwrites is not None else Overwrites() self.connections = connections if connections is not None else Connections() self.child_list = child_list @@ -429,7 +463,9 @@ def _read_xml(self, xml_node: "Element"): if _gdtf_spec is not None: self.gdtf_spec = _gdtf_spec.text if self.gdtf_spec is not None: - self.gdtf_spec = self.gdtf_spec.encode("utf-8").decode("cp437") # IBM PC encoding + self.gdtf_spec = self.gdtf_spec.encode("utf-8").decode( + "cp437" + ) # IBM PC encoding if self.gdtf_spec is not None and len(self.gdtf_spec) > 5: if self.gdtf_spec[-5:].lower() != ".gdtf": self.gdtf_spec = f"{self.gdtf_spec}.gdtf" @@ -466,7 +502,9 @@ def _read_xml(self, xml_node: "Element"): if xml_node.find("Connections"): self.connections = Connections(xml_node=xml_node.find("Connections")) if xml_node.find("CustomCommands") is not None: - self.custom_commands = CustomCommands(xml_node=xml_node.find("CustomCommands")) + self.custom_commands = CustomCommands( + xml_node=xml_node.find("CustomCommands") + ) if xml_node.find("Overwrites"): self.overwrites = Overwrites(xml_node=xml_node.find("Overwrites")) if xml_node.find("Classing") is not None: @@ -504,11 +542,15 @@ def populate_xml(self, element: Element): self.connections.to_xml(element) ElementTree.SubElement(element, "FixtureID").text = str(self.fixture_id) or "0" - ElementTree.SubElement(element, "FixtureIDNumeric").text = str(self.fixture_id_numeric) + ElementTree.SubElement(element, "FixtureIDNumeric").text = str( + self.fixture_id_numeric + ) if self.unit_number is not None: ElementTree.SubElement(element, "UnitNumber").text = str(self.unit_number) if self.custom_id_type is not None: - ElementTree.SubElement(element, "CustomIdType").text = str(self.custom_id_type) + ElementTree.SubElement(element, "CustomIdType").text = str( + self.custom_id_type + ) if self.custom_id is not None: ElementTree.SubElement(element, "CustomId").text = str(self.custom_id) @@ -565,7 +607,9 @@ def __str__(self): def to_xml(self): attributes = {"name": self.name, "uuid": self.uuid} - return ElementTree.Element(type(self).__name__, provider=self.provider, ver=self.ver) + return ElementTree.Element( + type(self).__name__, provider=self.provider, ver=self.ver + ) class AUXData(BaseNode): @@ -588,7 +632,9 @@ def _read_xml(self, xml_node: "Element"): self.classes = [Class(xml_node=i) for i in xml_node.findall("Class")] self.symdefs = [Symdef(xml_node=i) for i in xml_node.findall("Symdef")] self.positions = [Position(xml_node=i) for i in xml_node.findall("Position")] - self.mapping_definitions = [MappingDefinition(xml_node=i) for i in xml_node.findall("MappingDefinition")] + self.mapping_definitions = [ + MappingDefinition(xml_node=i) for i in xml_node.findall("MappingDefinition") + ] def to_xml(self, parent: Element): element = ElementTree.SubElement(parent, type(self).__name__) @@ -620,7 +666,9 @@ def __init__( self.size_x = size_x self.size_y = size_y self.source = source - self.scale_handling = scale_handling if scale_handling is not None else ScaleHandeling() + self.scale_handling = ( + scale_handling if scale_handling is not None else ScaleHandeling() + ) super().__init__(*args, **kwargs) def _read_xml(self, xml_node: "Element"): @@ -637,7 +685,9 @@ def _read_xml(self, xml_node: "Element"): self.scale_handling = ScaleHandeling(xml_node=scale_handling_node) def to_xml(self): - element = ElementTree.Element(type(self).__name__, name=self.name, uuid=self.uuid) + element = ElementTree.Element( + type(self).__name__, name=self.name, uuid=self.uuid + ) ElementTree.SubElement(element, "SizeX").text = str(self.size_x) ElementTree.SubElement(element, "SizeY").text = str(self.size_y) if self.scale_handling: @@ -784,7 +834,9 @@ def __str__(self): return f"{self.name}" def to_xml(self): - element = ElementTree.Element(type(self).__name__, name=self.name, uuid=self.uuid) + element = ElementTree.Element( + type(self).__name__, name=self.name, uuid=self.uuid + ) Matrix(self.matrix.matrix).to_xml(parent=element) if self.classing: ElementTree.SubElement(element, "Classing").text = self.classing @@ -850,18 +902,26 @@ def __init__( super().__init__(*args, **kwargs) def _read_xml(self, xml_node: "Element"): - self.scene_objects = [SceneObject(xml_node=i) for i in xml_node.findall("SceneObject")] + self.scene_objects = [ + SceneObject(xml_node=i) for i in xml_node.findall("SceneObject") + ] - self.group_objects = [GroupObject(xml_node=i) for i in xml_node.findall("GroupObject")] + self.group_objects = [ + GroupObject(xml_node=i) for i in xml_node.findall("GroupObject") + ] - self.focus_points = [FocusPoint(xml_node=i) for i in xml_node.findall("FocusPoint")] + self.focus_points = [ + FocusPoint(xml_node=i) for i in xml_node.findall("FocusPoint") + ] self.fixtures = [Fixture(xml_node=i) for i in xml_node.findall("Fixture")] self.supports = [Support(xml_node=i) for i in xml_node.findall("Support")] self.trusses = [Truss(xml_node=i) for i in xml_node.findall("Truss")] - self.video_screens = [VideoScreen(xml_node=i) for i in xml_node.findall("VideoScreen")] + self.video_screens = [ + VideoScreen(xml_node=i) for i in xml_node.findall("VideoScreen") + ] self.projectors = [Projector(xml_node=i) for i in xml_node.findall("Projector")] @@ -914,7 +974,9 @@ def _read_xml(self, xml_node: "Element"): self.matrix = Matrix(str_repr=xml_node.find("Matrix").text) def to_xml(self): - element = ElementTree.Element(type(self).__name__, name=self.name, uuid=self.uuid) + element = ElementTree.Element( + type(self).__name__, name=self.name, uuid=self.uuid + ) Matrix(self.matrix.matrix).to_xml(parent=element) if self.child_list: self.child_list.to_xml(parent=element) @@ -965,7 +1027,9 @@ def to_xml(self, addresses): universes = 512 * (self.universe - 1) raw_address = self.address + universes - address = ElementTree.SubElement(addresses, "Address", attrib={"break": str(self.dmx_break)}) + address = ElementTree.SubElement( + addresses, "Address", attrib={"break": str(self.dmx_break)} + ) address.text = str(raw_address) @@ -989,7 +1053,9 @@ def __str__(self): return f"{self.name}" def to_xml(self): - element = ElementTree.Element(type(self).__name__, name=self.name, uuid=self.uuid) + element = ElementTree.Element( + type(self).__name__, name=self.name, uuid=self.uuid + ) return element @@ -1013,7 +1079,9 @@ def __str__(self): return f"{self.name}" def to_xml(self): - element = ElementTree.Element(type(self).__name__, name=self.name, uuid=self.uuid) + element = ElementTree.Element( + type(self).__name__, name=self.name, uuid=self.uuid + ) return element @@ -1040,7 +1108,9 @@ def _read_xml(self, xml_node: "Element"): child_list = xml_node.find("ChildList") if child_list is not None: self.symbol = [Symbol(xml_node=i) for i in child_list.findall("Symbol")] - _geometry3d = [Geometry3D(xml_node=i) for i in child_list.findall("Geometry3D")] + _geometry3d = [ + Geometry3D(xml_node=i) for i in child_list.findall("Geometry3D") + ] else: self.symbol = [] _geometry3d = [] @@ -1049,7 +1119,9 @@ def _read_xml(self, xml_node: "Element"): self.geometry3d = list(set(_geometry3d)) def to_xml(self): - element = ElementTree.Element(type(self).__name__, name=self.name, uuid=self.uuid) + element = ElementTree.Element( + type(self).__name__, name=self.name, uuid=self.uuid + ) for geo in self.geometry3d: element.append(geo.to_xml()) for sym in self.symbol: @@ -1070,7 +1142,9 @@ def __init__( super().__init__(*args, **kwargs) def _read_xml(self, xml_node: "Element"): - self.file_name = xml_node.attrib.get("fileName", "").encode("utf-8").decode("cp437") + self.file_name = ( + xml_node.attrib.get("fileName", "").encode("utf-8").decode("cp437") + ) if xml_node.find("Matrix") is not None: self.matrix = Matrix(str_repr=xml_node.find("Matrix").text) @@ -1119,7 +1193,9 @@ def __str__(self): return f"{self.uuid}" def to_xml(self): - element = ElementTree.Element(type(self).__name__, uuid=self.uuid, symdef=self.symdef) + element = ElementTree.Element( + type(self).__name__, uuid=self.uuid, symdef=self.symdef + ) Matrix(self.matrix.matrix).to_xml(parent=element) return element @@ -1138,7 +1214,9 @@ def __init__( def _read_xml(self, xml_node: "Element"): self.symbol = [Symbol(xml_node=i) for i in xml_node.findall("Symbol")] - self.geometry3d = [Geometry3D(xml_node=i) for i in xml_node.findall("Geometry3D")] + self.geometry3d = [ + Geometry3D(xml_node=i) for i in xml_node.findall("Geometry3D") + ] def to_xml(self, parent: Element): element = ElementTree.SubElement(parent, type(self).__name__) @@ -1184,7 +1262,9 @@ def __str__(self): return f"{self.name}" def to_xml(self): - element = ElementTree.Element(type(self).__name__, name=self.name, uuid=self.uuid) + element = ElementTree.Element( + type(self).__name__, name=self.name, uuid=self.uuid + ) Matrix(self.matrix.matrix).to_xml(parent=element) if self.classing: ElementTree.SubElement(element, "Classing").text = self.classing @@ -1599,7 +1679,9 @@ def __init__( **kwargs, ): self.source = source - self.scale_handling = scale_handling if scale_handling is not None else ScaleHandeling() + self.scale_handling = ( + scale_handling if scale_handling is not None else ScaleHandeling() + ) super().__init__(*args, **kwargs) def _read_xml(self, xml_node: "Element"): @@ -1630,7 +1712,9 @@ def __init__( super().__init__(xml_node, *args, **kwargs) def _read_xml(self, xml_node: "Element"): - self.projections = [Projection(xml_node=i) for i in xml_node.findall("Projection")] + self.projections = [ + Projection(xml_node=i) for i in xml_node.findall("Projection") + ] def to_xml(self, parent: Element): element = ElementTree.SubElement(parent, type(self).__name__) diff --git a/pymvr/value.py b/pymvr/value.py index cc59e68..0fc5001 100644 --- a/pymvr/value.py +++ b/pymvr/value.py @@ -1,3 +1,27 @@ +# The MIT License (MIT) +# +# Copyright (C) 2023 vanous +# +# This file is part of pymvr. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the “Software”), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + from typing import List, Union from xml.etree import ElementTree diff --git a/pyproject.toml b/pyproject.toml index 386b839..569e9b3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,27 @@ +# The MIT License (MIT) +# +# Copyright (C) 2024 vanous +# +# This file is part of pymvr. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the “Software”), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + [build-system] requires = ["setuptools"] build-backend = "setuptools.build_meta" @@ -30,6 +54,7 @@ version = {attr = "pymvr.__version__"} [dependency-groups] dev = [ + "pre-commit>=3.5.0", "pytest>=8.3.4", "pytest-mypy>=0.10.3", "ruff>=0.9.3", diff --git a/ruff.toml b/ruff.toml deleted file mode 100644 index 7a3f6a3..0000000 --- a/ruff.toml +++ /dev/null @@ -1 +0,0 @@ -line-length = 160 diff --git a/tests/test_fixture_1_5.py b/tests/test_fixture_1_5.py index 9af5ac6..ce9484b 100644 --- a/tests/test_fixture_1_5.py +++ b/tests/test_fixture_1_5.py @@ -1,3 +1,27 @@ +# The MIT License (MIT) +# +# Copyright (C) 2023 vanous +# +# This file is part of pymvr. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the “Software”), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + import pytest @@ -22,7 +46,9 @@ def process_mvr_child_list(child_list, mvr_scene): def process_mvr_fixture(fixture): assert fixture.gdtf_spec == "LED PAR 64 RGBW.gdtf" - assert fixture.addresses.address[0].universe == 1 # even though the uni is 0 in the file, 1 is by the spec + assert ( + fixture.addresses.address[0].universe == 1 + ) # even though the uni is 0 in the file, 1 is by the spec assert fixture.addresses.address[0].address == 1 # dtto assert fixture.gdtf_mode == "Default" assert fixture.matrix.matrix[3] == [5.0, 5.0, 5.0, 0] diff --git a/tests/test_fixture_scene_object_1_5.py b/tests/test_fixture_scene_object_1_5.py index 6f50b0b..e19877d 100644 --- a/tests/test_fixture_scene_object_1_5.py +++ b/tests/test_fixture_scene_object_1_5.py @@ -1,3 +1,27 @@ +# The MIT License (MIT) +# +# Copyright (C) 2023 vanous +# +# This file is part of pymvr. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the “Software”), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + import pytest diff --git a/tests/test_group_objects_1_4.py b/tests/test_group_objects_1_4.py index 0e9ce00..2738420 100644 --- a/tests/test_group_objects_1_4.py +++ b/tests/test_group_objects_1_4.py @@ -1,3 +1,27 @@ +# The MIT License (MIT) +# +# Copyright (C) 2023 vanous +# +# This file is part of pymvr. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the “Software”), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + import pytest @@ -11,10 +35,19 @@ def test_version(mvr_scene): @pytest.mark.parametrize("mvr_scene", [("capture_demo_show.mvr",)], indirect=True) def test_auxdata(mvr_scene): """Check symdefs""" - assert mvr_scene.scene.aux_data.symdefs[0].uuid == "12fcdd5e-4194-56a0-96de-1c3c4edf1cd3" + assert ( + mvr_scene.scene.aux_data.symdefs[0].uuid + == "12fcdd5e-4194-56a0-96de-1c3c4edf1cd3" + ) @pytest.mark.parametrize("mvr_scene", [("capture_demo_show.mvr",)], indirect=True) def test_child_list(mvr_scene): - assert mvr_scene.scene.layers[1].child_list.fixtures[0].uuid == "2e149740-6a41-bc43-bd59-8968781b11b9" - assert mvr_scene.scene.layers[2].child_list.scene_objects[1].uuid == "d1d76649-35bd-9d49-baa4-abcb481fb2c8" + assert ( + mvr_scene.scene.layers[1].child_list.fixtures[0].uuid + == "2e149740-6a41-bc43-bd59-8968781b11b9" + ) + assert ( + mvr_scene.scene.layers[2].child_list.scene_objects[1].uuid + == "d1d76649-35bd-9d49-baa4-abcb481fb2c8" + ) diff --git a/tests/test_mvr_01_write_ours.py b/tests/test_mvr_01_write_ours.py index 4e55596..5ac0b5d 100644 --- a/tests/test_mvr_01_write_ours.py +++ b/tests/test_mvr_01_write_ours.py @@ -1,3 +1,27 @@ +# The MIT License (MIT) +# +# Copyright (C) 2024 vanous +# +# This file is part of pymvr. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the “Software”), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + import pytest from pathlib import Path import pymvr diff --git a/tests/test_mvr_02_read_ours.py b/tests/test_mvr_02_read_ours.py index 4802030..bcc0ce7 100644 --- a/tests/test_mvr_02_read_ours.py +++ b/tests/test_mvr_02_read_ours.py @@ -1,3 +1,27 @@ +# The MIT License (MIT) +# +# Copyright (C) 2024 vanous +# +# This file is part of pymvr. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the “Software”), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + import pytest diff --git a/tests/test_mvr_03_write_ours_json.py b/tests/test_mvr_03_write_ours_json.py index 19e454c..bbfa0d3 100644 --- a/tests/test_mvr_03_write_ours_json.py +++ b/tests/test_mvr_03_write_ours_json.py @@ -1,3 +1,27 @@ +# The MIT License (MIT) +# +# Copyright (C) 2025 vanous +# +# This file is part of pymvr. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the “Software”), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + from pathlib import Path import pymvr @@ -37,7 +61,12 @@ def test_write_from_json(): for fixture_data in layer_data["fixtures"]: new_addresses = [ - pymvr.Address(dmx_break=address["dmx_break"], address=address["address"], universe=address["universe"]) for address in fixture_data["addresses"] + pymvr.Address( + dmx_break=address["dmx_break"], + address=address["address"], + universe=address["universe"], + ) + for address in fixture_data["addresses"] ] new_fixture = pymvr.Fixture( diff --git a/tests/test_mvr_04_read_ours_json.py b/tests/test_mvr_04_read_ours_json.py index e66d5d9..4f07db9 100644 --- a/tests/test_mvr_04_read_ours_json.py +++ b/tests/test_mvr_04_read_ours_json.py @@ -1,3 +1,27 @@ +# The MIT License (MIT) +# +# Copyright (C) 2025 vanous +# +# This file is part of pymvr. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the “Software”), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + import pytest diff --git a/tests/test_mvr_05_example.py b/tests/test_mvr_05_example.py index 0e9b432..e145d04 100644 --- a/tests/test_mvr_05_example.py +++ b/tests/test_mvr_05_example.py @@ -1,3 +1,27 @@ +# The MIT License (MIT) +# +# Copyright (C) 2025 vanous +# +# This file is part of pymvr. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the “Software”), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + from pathlib import Path import pymvr diff --git a/tests/test_with_files.py b/tests/test_with_files.py index 1500183..0240486 100644 --- a/tests/test_with_files.py +++ b/tests/test_with_files.py @@ -1,20 +1,20 @@ -# MIT License +# The MIT License (MIT) # # Copyright (C) 2025 vanous # -# This file is part of pygdtf. +# This file is part of pymvr. # -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the “Software”), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER