1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
# This file is auto-generated by CMake, do not edit!
# Refer to python/__init__.py.in source file
import os
import re
import sys
import warnings
from pathlib import Path
from typing import Any, Iterable, Mapping, Union
F3D_ABSOLUTE_DLLS = [
# @F3D_ABSOLUTE_DLLS_FIXUP@
]
F3D_RELATIVE_DLLS = [
# @F3D_RELATIVE_DLLS_FIXUP@
]
if sys.version_info >= (3, 8) and sys.platform == "win32":
for abs_path in F3D_ABSOLUTE_DLLS:
os.add_dll_directory(abs_path)
root = Path(__file__).parent
for rel_path in F3D_RELATIVE_DLLS:
os.add_dll_directory((root / rel_path).resolve())
from .pyf3d import *
# Automatically load plugins for the user
Engine.autoload_plugins()
__version__ = "@F3D_VERSION@"
################################################################################
# monkey patch `options.update`
def _f3d_options_update(
self, arg: Union[Mapping[str, Any], Iterable[tuple[str, Any]]]
) -> None:
try:
for k, v in arg.items():
self[k] = v
return
except AttributeError: # `arg` doesn't have `.items()`
pass
try:
for k, v in arg:
self[k] = v
return
except TypeError: # `arg` isn't iterable
pass
except ValueError: # `arg` isn't iterable of pairs
pass
raise ValueError(f"cannot update {self} from {arg}")
Options.update = _f3d_options_update
################################################################################
# add deprecated warnings
def _deprecated_decorator(f, reason):
def g(*args, **kwargs):
warnings.warn(reason, DeprecationWarning, 2)
return f(*args, **kwargs)
return g
def _add_deprecation_warnings():
for f3d_class in (
Camera,
Scene,
Options,
Interactor,
Engine,
Window,
Image,
):
for name, member in f3d_class.__dict__.items():
if callable(member) and member.__doc__:
m = re.search(r"DEPRECATED(:\s*.+)?", member.__doc__)
if m:
reason = m.group(1) or ""
msg = f"{f3d_class.__qualname__}.{name} is deprecated{reason}"
setattr(f3d_class, name, _deprecated_decorator(member, msg))
_add_deprecation_warnings()
|