MCPcopy Index your code
hub / github.com/python/cpython / make_script

Function make_script

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

Source from the content-addressed store, hash-verified

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

Calls 4

openFunction · 0.50
joinMethod · 0.45
writeMethod · 0.45
invalidate_cachesMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…