simvx.core.scene_io.scene_module¶
Folder-as-scene editing surface.
This is Tier 4 of the scene I/O layer. A scene module is a Python package
whose __init__.py (or, as a namespaced fallback, <folder>/<folder>.py)
defines the primary :class:Node subclass; sibling .py files inside the
folder hold sub-scenes that the root imports relatively. SceneModule is
the multi-file analog of :class:SceneFile: it owns one root SceneFile
plus zero or more sibling SceneFile instances, all editable, with
- meth:
saveflushing every dirty file in one pass.
Module Contents¶
Classes¶
A folder scene: a Python package whose |
Data¶
API¶
- simvx.core.scene_io.scene_module.__all__¶
[‘NotASceneModuleError’, ‘SceneModule’]
- exception simvx.core.scene_io.scene_module.NotASceneModuleError[source]¶
Bases:
ValueErrorRaised when a folder doesn’t qualify as a scene module.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- class __cause__¶
- class __context__¶
- __delattr__()¶
- __dir__()¶
- __eq__()¶
- __format__()¶
- __ge__()¶
- __getattribute__()¶
- __getstate__()¶
- __gt__()¶
- __hash__()¶
- __le__()¶
- __lt__()¶
- __ne__()¶
- __new__()¶
- __reduce__()¶
- __reduce_ex__()¶
- __repr__()¶
- __setattr__()¶
- __setstate__()¶
- __sizeof__()¶
- __str__()¶
- __subclasshook__()¶
- class __suppress_context__¶
- class __traceback__¶
- add_note()¶
- class args¶
- with_traceback()¶
- class simvx.core.scene_io.scene_module.SceneModule(folder: pathlib.Path, root_path: pathlib.Path, root: simvx.core.scene_io.scene_file.SceneFile)[source]¶
A folder scene: a Python package whose
__init__.py(or a<folder>/<folder_name>.pynamespaced fallback) defines the primary Node subclass, with sibling.pyfiles holding sub-scenes that the root imports.SceneModule is the multi-file analog of SceneFile: it owns one root SceneFile plus zero or more sibling SceneFiles, all editable, with save() flushing every dirty file.
Initialization
- __slots__¶
(‘_folder’, ‘_root_path’, ‘_root’, ‘_files’, ‘_to_delete’, ‘_added’)
- classmethod load(folder: str | pathlib.Path) simvx.core.scene_io.scene_module.SceneModule[source]¶
Open a folder scene. Resolution order:
folder/__init__.pyif it defines exactly one Node subclass.folder/<folder_name>.pyas a namespaced fallback.
Raises :class:
NotASceneModuleErrorif neither matches. Raises- Class:
AmbiguousSceneErrorif either matching file has multiple Node subclasses.
- static is_folder_scene(path: str | pathlib.Path) bool[source]¶
True iff
pathqualifies as a scene module under the same rules as :meth:load. False for files, missing paths, and folders that don’t match either resolution rule.
- property root: simvx.core.scene_io.scene_file.SceneFile[source]¶
SceneFile for the root scene definition (whichever of
__init__.pyor<folder_name>.pywas selected).
- files() list[simvx.core.scene_io.scene_file.SceneFile][source]¶
Every
.pySceneFile open for editing under this module (the root plus any opened sub-scenes), in stable order.
- file(name: str) simvx.core.scene_io.scene_file.SceneFile[source]¶
Open (or return cached) the sibling file
<name>.pyas a SceneFile.nameis the module stem, not a full path.Raises :class:
FileNotFoundErrorif the file doesn’t exist.
- add_file(name: str, source: str) simvx.core.scene_io.scene_file.SceneFile[source]¶
Create a new sibling file
<name>.pywith the given source.Returns the cached SceneFile. Raises :class:
FileExistsErrorif the file already exists. The file is staged in memory until- Meth:
save.
- remove_file(name: str) None[source]¶
Mark a sibling file for deletion on :meth:
save.Raises :class:
FileNotFoundErrorif the file doesn’t exist on disk and wasn’t staged via :meth:add_file. The corresponding SceneFile cache entry is dropped immediately.
- split_child(child_var: str, into_file: str) simvx.core.scene_io.scene_file.SceneFile[source]¶
Extract the child constructed by
<child_var>in the root’s__init__into a sibling file<into_file>.py.The new file contains a Node subclass whose body matches the original child construction plus any subsequent
__init__statements that reference<child_var>(e.g.<child_var>.add_child(Weapon())or<child_var>.scale = ...). The root’s child line becomes<child_var> = <NewClass>()and a relative import is added; the lifted statements are removed from the root’s__init__.Refuses (raises :class:
ValueError) if any lift candidate:lives inside a loop / conditional / try / with block
depends on a helper variable assigned earlier in
__init__(the user must inline the helper into the lifted construction first, or restructure manually).
Returns the new SceneFile. Raises if
<child_var>is not in the root, or if<into_file>.pyalready exists.
- inline_file(child_path: str) None[source]¶
Inverse of :meth:
split_child. Inline the named sub-scene back into the root: replace the<var> = <CustomClass>()line with a construction call (and child kwargs) matching the inlined class, remove the relative import, and :meth:remove_filethe named file.Raises if the named class is not currently used by the root, or if the file is not a clean leaf scene module (e.g. has procedural construction).