Skip to content

Commit c58ff86

Browse files
Merge pull request #2605 from fgallaire/loadBrythonPackage
Add JS convenient function loadBrythonPackage
2 parents e43aa13 + ae95883 commit c58ff86

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

setup/brython/make_package.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ def make(package_name, package_path, exclude_dirs=None, output_path=None):
111111

112112
output_path = output_path or os.path.join(package_path, package_name + ".brython.js")
113113
with open(output_path, "w", encoding="utf-8") as out:
114-
out.write('__BRYTHON__.use_VFS = true;\n')
115-
out.write('var scripts = {}\n'.format(json.dumps(VFS)))
116-
out.write('__BRYTHON__.update_VFS(scripts)\n')
114+
out.write(f'__BRYTHON__.loadBrythonPackage({json.dumps(VFS)})\n')
117115

118116
if __name__ == "__main__":
119117
import sys

www/src/brython_builtins.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,11 @@ $B.update_VFS = function(scripts){
467467
$B.stdlib_module_names = Object.keys($B.VFS)
468468
}
469469

470+
$B.loadBrythonPackage = function(brythonPackage){
471+
$B.use_VFS = true
472+
$B.update_VFS(brythonPackage)
473+
}
474+
470475
$B.add_files = function(files){
471476
// Used to add files that programs can open with open()
472477
$B.files = $B.files || {}

0 commit comments

Comments
 (0)