simvx.editor.live_file_ops

Live Python file operations mixin for State.

Module Contents

Classes

LiveFileOps

Mixin for opening Python scene files and working with live Node objects.

FileWatcher

Polls file mtimes to detect external modifications.

Data

log

API

simvx.editor.live_file_ops.log

‘getLogger(…)’

class simvx.editor.live_file_ops.LiveFileOps[source]

Mixin for opening Python scene files and working with live Node objects.

Replaces JSON-based scene loading with a workflow where the editor imports Python files, identifies Node subclasses, instantiates them, and manipulates live objects. Properties are read from instances via get_properties().

open_file(path: str | pathlib.Path) None[source]

Open a Python file, import it, and instantiate its primary Node class.

instantiate_class(cls: type) simvx.core.Node | None[source]

Safely instantiate a Node subclass. Returns None on error.

classify_file(module: types.ModuleType, file_path: str) str[source]

Classify a Python file. Returns ‘main’, ‘scene’, or ‘node’.

find_node_classes(module: types.ModuleType) list[tuple[str, type]][source]

Find all Node subclasses defined in a module.

get_primary_class(module: types.ModuleType, file_path: str) type | None[source]

Get the primary class to instantiate from a module.

Priority: Main > filename match > sole class > None

class simvx.editor.live_file_ops.FileWatcher[source]

Polls file mtimes to detect external modifications.

Usage::

watcher = FileWatcher()
watcher.watch("/path/to/player.py")
# Periodically:
changed = watcher.check()  # returns list of changed paths

Initialization

watch(path: str | pathlib.Path) None[source]

Start watching a file. Records its current mtime.

unwatch(path: str | pathlib.Path) None[source]

Stop watching a file.

watch_directory(directory: str | pathlib.Path, suffix: str = '.py') None[source]

Watch all files with given suffix in a directory tree.

check() list[str][source]

Check all watched files for mtime changes. Returns list of changed paths.

clear() None[source]

Stop watching all files.