Skip to main content

Provides a directory with all its parent directories, if it does not yet exist

Project description

provide_directory

Function to create the given path, including potential parent directories. Returns a bool if at leas one directory as been created.

Dependencies

None

Usage

from pathlib import Path
from provide_dir import provide_dir

needed_path = Path("/path/to/directory/with/subdirectories")

try:
    was_created = provide_path(needed_path)
    if was_created:
        print(f"{needed_path} was successfully created")
    else:
        print(f"{needed_path} already exists")
except FileExistsError:
    print(f"Cannot create {needed_path} because it already exists as a file")

Installation

Pip

pip install provide_dir

Developer's Installation

You can clone the repository and install it with pip install -e /path/to/local/repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

provide_dir-0.0.2.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

provide_dir-0.0.2-py3-none-any.whl (3.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page