How to use the yoga.model.options.normalize_options function in yoga

To help you get started, we’ve selected a few yoga examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wanadev / yoga / test / test_model_options.py View on Github external
def test_output_format_option(self):
        opt = options.normalize_options({"output_format": "glb"})
        assert opt["output_format"] == "glb"

        opt = options.normalize_options({"output_format": "gltf"})
        assert opt["output_format"] == "gltf"

        opt = options.normalize_options({"output_format": "glTF"})
        assert opt["output_format"] == "gltf"

        with pytest.raises(ValueError):
            options.normalize_options({"output_format": "foobar"})
github wanadev / yoga / test / test_model_options.py View on Github external
def test_no_parameter_returns_default_options(self):
        opt = options.normalize_options()

        assert opt is not options.DEFAULT_OPTIONS

        for k, v in options.DEFAULT_OPTIONS.items():
            assert k in opt
            assert opt[k] == v
github wanadev / yoga / test / test_model_options.py View on Github external
def test_no_textures_optimization(self):
        opt = options.normalize_options({"no_textures_optimization": True})
        assert opt["no_textures_optimization"] is True

        opt = options.normalize_options({"no_textures_optimization": False})
        assert opt["no_textures_optimization"] is False

        opt = options.normalize_options({"no_textures_optimization": ""})
        assert opt["no_textures_optimization"] is False

        opt = options.normalize_options({"no_textures_optimization": "foobar"})
        assert opt["no_textures_optimization"] is True
github wanadev / yoga / test / test_model_options.py View on Github external
def test_no_meshes_optimization(self):
        opt = options.normalize_options({"no_meshes_optimization": True})
        assert opt["no_meshes_optimization"] is True

        opt = options.normalize_options({"no_meshes_optimization": False})
        assert opt["no_meshes_optimization"] is False

        opt = options.normalize_options({"no_meshes_optimization": ""})
        assert opt["no_meshes_optimization"] is False

        opt = options.normalize_options({"no_meshes_optimization": "foobar"})
        assert opt["no_meshes_optimization"] is True
github wanadev / yoga / test / test_model_options.py View on Github external
def test_no_graph_optimization(self):
        opt = options.normalize_options({"no_graph_optimization": True})
        assert opt["no_graph_optimization"] is True

        opt = options.normalize_options({"no_graph_optimization": False})
        assert opt["no_graph_optimization"] is False

        opt = options.normalize_options({"no_graph_optimization": ""})
        assert opt["no_graph_optimization"] is False

        opt = options.normalize_options({"no_graph_optimization": "foobar"})
        assert opt["no_graph_optimization"] is True
github wanadev / yoga / test / test_model_options.py View on Github external
def test_no_meshes_optimization(self):
        opt = options.normalize_options({"no_meshes_optimization": True})
        assert opt["no_meshes_optimization"] is True

        opt = options.normalize_options({"no_meshes_optimization": False})
        assert opt["no_meshes_optimization"] is False

        opt = options.normalize_options({"no_meshes_optimization": ""})
        assert opt["no_meshes_optimization"] is False

        opt = options.normalize_options({"no_meshes_optimization": "foobar"})
        assert opt["no_meshes_optimization"] is True
github wanadev / yoga / test / test_model_options.py View on Github external
def test_output_format_option(self):
        opt = options.normalize_options({"output_format": "glb"})
        assert opt["output_format"] == "glb"

        opt = options.normalize_options({"output_format": "gltf"})
        assert opt["output_format"] == "gltf"

        opt = options.normalize_options({"output_format": "glTF"})
        assert opt["output_format"] == "gltf"

        with pytest.raises(ValueError):
            options.normalize_options({"output_format": "foobar"})
github wanadev / yoga / yoga / model / __init__.py View on Github external
def optimize(input_file, output_file, options={}, textures=None,
             verbose=False, quiet=False):
    # TODO: Make a effective documentation.
    # The textures arguments should be a dictionary that maps
    # paths to bytes. When not None, there will be no file system
    # reads in order to find referenced textures. We will
    # look into that dictionary instead.

    model_options = normalize_options(options)
    image_options = extract_image_options(options)

    if quiet:
        verbose = False

    # Open file if possible
    if not hasattr(input_file, "read"):
        input_file = open(input_file, "rb")

    root_path = None
    if hasattr(input_file, "name"):
        root_path = os.path.dirname(os.path.abspath(input_file.name))

    # input_file -> string (path), bytes, file-like
    if hasattr(input_file, "read"):
        input_file = input_file.read()