MCPcopy
hub / github.com/pex-tool/pex / safe_open

Function safe_open

pex/common.py:588–597  ·  view source on GitHub ↗

Safely open a file. ``safe_open`` ensures that the directory components leading up the specified file have been created first.

(filename, *args, **kwargs)

Source from the content-addressed store, hash-verified

586
587
588def safe_open(filename, *args, **kwargs):
589 """Safely open a file.
590
591 ``safe_open`` ensures that the directory components leading up the specified file have been
592 created first.
593 """
594 parent_dir = os.path.dirname(filename)
595 if parent_dir:
596 safe_mkdir(parent_dir)
597 return open(filename, *args, **kwargs) # noqa: T802
598
599
600def safe_delete(filename):

Callers 15

install_scriptsFunction · 0.90
finalize_logMethod · 0.90
writeMethod · 0.90
install_wheelFunction · 0.90
writeMethod · 0.90
_build_zipappMethod · 0.90
_extractMethod · 0.90
create_manifestsFunction · 0.90
recordMethod · 0.90
launchMethod · 0.90
outputMethod · 0.90
_load_stubFunction · 0.90

Calls 1

safe_mkdirFunction · 0.85