Advance N-023 through N-026 audited parity
This commit is contained in:
32
tools/web/generate-script-fixture.py
Normal file
32
tools/web/generate-script-fixture.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
SOURCES = {
|
||||
"InternalSafe.py": "value = 7\nprint(value)\n",
|
||||
"ModuleAutorun.py": "def register():\n return 'blocked'\n",
|
||||
"ExternalProject.py": "message = 'project relative'\n",
|
||||
}
|
||||
|
||||
|
||||
def main(output_path):
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
for name, source in SOURCES.items():
|
||||
text = bpy.data.texts.new(name)
|
||||
text.write(source)
|
||||
bpy.data.texts["ModuleAutorun.py"].use_module = True
|
||||
bpy.data.texts["ExternalProject.py"].filepath = "//scripts/external_project.py"
|
||||
|
||||
path = pathlib.Path(output_path).resolve()
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=str(path), compress=False)
|
||||
print(f"script-fixture-generated path={path} sources={len(SOURCES)}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
arguments = sys.argv[sys.argv.index("--") + 1:]
|
||||
if len(arguments) != 1:
|
||||
raise SystemExit("usage: blender -b --python generate-script-fixture.py -- output.blend")
|
||||
main(arguments[0])
|
||||
Reference in New Issue
Block a user