MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / initialize_bbim_semver

Function initialize_bbim_semver

src/bonsai/bonsai/__init__.py:99–117  ·  view source on GitHub ↗

Initialize `bbim_semver` dictionary. Blender doesn't seem to store a full extension version (only major-minor-patch) in `addon_utils.modules()->bl_info['version']`, therefore we just parse it from .toml.

()

Source from the content-addressed store, hash-verified

97
98
99def initialize_bbim_semver():
100 """Initialize `bbim_semver` dictionary.
101
102 Blender doesn't seem to store a full extension version (only major-minor-patch)
103 in `addon_utils.modules()->bl_info['version']`,
104 therefore we just parse it from .toml.
105 """
106 import tomllib
107
108 toml_path = Path(__file__).parent / "blender_manifest.toml"
109 with open(toml_path, "rb") as f:
110 manifest = tomllib.load(f)
111 semver_pattern = r"^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
112 version_str = manifest["version"]
113 re_version = re.match(semver_pattern, version_str)
114 assert re_version
115 global bbim_semver
116 bbim_semver = re_version.groupdict()
117 bbim_semver["version"] = version_str
118
119
120def get_debug_info(*, bonsai_failed_to_load: bool = False) -> dict[str, Any]:

Callers 1

__init__.pyFile · 0.85

Calls 3

openFunction · 0.50
loadMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected