MCPcopy Create free account
hub / github.com/openai/openai-agents-python / ensure_dirs

Function ensure_dirs

examples/run_examples.py:574–585  ·  view source on GitHub ↗

Create directories for a file or directory path. If `is_file` is True, always create the parent directory. If False, create the directory itself. When None, treat paths with a suffix as files and others as directories, but suffix-less file names should pass is_file=True to avoid acc

(path: Path, is_file: bool | None = None)

Source from the content-addressed store, hash-verified

572
573
574def ensure_dirs(path: Path, is_file: bool | None = None) -> None:
575 """Create directories for a file or directory path.
576
577 If `is_file` is True, always create the parent directory. If False, create the
578 directory itself. When None, treat paths with a suffix as files and others as
579 directories, but suffix-less file names should pass is_file=True to avoid
580 accidental directory creation.
581 """
582 if is_file is None:
583 is_file = bool(path.suffix)
584 target = path.parent if is_file else path
585 target.mkdir(parents=True, exist_ok=True)
586
587
588def artifact_dir_for_example(relpath: str, artifacts_dir: Path) -> Path:

Callers 3

run_examplesFunction · 0.85
run_singleFunction · 0.85
mainFunction · 0.85

Calls 1

mkdirMethod · 0.45

Tested by

no test coverage detected