MCPcopy Index your code
hub / github.com/RustPython/RustPython / make_script

Function make_script

Lib/test/support/script_helper.py:231–244  ·  view source on GitHub ↗
(script_dir, script_basename, source, omit_suffix=False)

Source from the content-addressed store, hash-verified

229
230
231def make_script(script_dir, script_basename, source, omit_suffix=False):
232 script_filename = script_basename
233 if not omit_suffix:
234 script_filename += os.extsep + 'py'
235 script_name = os.path.join(script_dir, script_filename)
236 if isinstance(source, str):
237 # The script should be encoded to UTF-8, the default string encoding
238 with open(script_name, 'w', encoding='utf-8') as script_file:
239 script_file.write(source)
240 else:
241 with open(script_name, 'wb') as script_file:
242 script_file.write(source)
243 importlib.invalidate_caches()
244 return script_name
245
246
247def make_zip_script(zip_dir, zip_basename, script_name, name_in_zip=None):

Callers 10

_make_test_scriptMethod · 0.90
test_lost_io_openMethod · 0.90
_make_test_scriptFunction · 0.90
_make_test_scriptFunction · 0.90
_make_launch_scriptFunction · 0.90
make_pkgFunction · 0.85
make_zip_pkgFunction · 0.85

Calls 5

isinstanceFunction · 0.85
openFunction · 0.50
joinMethod · 0.45
writeMethod · 0.45
invalidate_cachesMethod · 0.45

Tested by 8

_make_test_scriptMethod · 0.72
test_lost_io_openMethod · 0.72
_make_test_scriptFunction · 0.72
_make_test_scriptFunction · 0.72
_make_launch_scriptFunction · 0.72