mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-04-30 10:47:34 +02:00
Move Graph.IO internal class to its own module, and rename it to `GraphIO`. This avoid nested classes within the core Graph class, and starts decoupling the management of graph's IO from the logic of the graph itself.
56 lines
1.5 KiB
Python
56 lines
1.5 KiB
Python
from enum import Enum
|
|
from typing import Union
|
|
|
|
from meshroom.core import Version
|
|
|
|
|
|
class GraphIO:
|
|
"""Centralize Graph file keys and IO version."""
|
|
|
|
__version__ = "2.0"
|
|
|
|
class Keys(object):
|
|
"""File Keys."""
|
|
|
|
# Doesn't inherit enum to simplify usage (GraphIO.Keys.XX, without .value)
|
|
Header = "header"
|
|
NodesVersions = "nodesVersions"
|
|
ReleaseVersion = "releaseVersion"
|
|
FileVersion = "fileVersion"
|
|
Graph = "graph"
|
|
|
|
class Features(Enum):
|
|
"""File Features."""
|
|
|
|
Graph = "graph"
|
|
Header = "header"
|
|
NodesVersions = "nodesVersions"
|
|
PrecomputedOutputs = "precomputedOutputs"
|
|
NodesPositions = "nodesPositions"
|
|
|
|
@staticmethod
|
|
def getFeaturesForVersion(fileVersion: Union[str, Version]) -> tuple["GraphIO.Features",...]:
|
|
"""Return the list of supported features based on a file version.
|
|
|
|
Args:
|
|
fileVersion (str, Version): the file version
|
|
|
|
Returns:
|
|
tuple of GraphIO.Features: the list of supported features
|
|
"""
|
|
if isinstance(fileVersion, str):
|
|
fileVersion = Version(fileVersion)
|
|
|
|
features = [GraphIO.Features.Graph]
|
|
if fileVersion >= Version("1.0"):
|
|
features += [
|
|
GraphIO.Features.Header,
|
|
GraphIO.Features.NodesVersions,
|
|
GraphIO.Features.PrecomputedOutputs,
|
|
]
|
|
|
|
if fileVersion >= Version("1.1"):
|
|
features += [GraphIO.Features.NodesPositions]
|
|
|
|
return tuple(features)
|
|
|