Skip to main content

This package finds the root directory of a project by traversing the ancestors directories starting at a given path.

Project description

Root Folder Search

This package finds the root directory of a project by recursively traversing parent directories starting at a given path.

I used it to overcome a limitation in Jupyter Notebooks, that doesn't provide the __file__ variable that would let me easily find the root folder of a project, regardless the current working directory. You might find it useful in other scenarios.

How to use

import rootfoldersearch

# returns a string with the absolute path to the root folder, where is located, starting the search in the CWD.

# the same, but using a file in a subfolder as reference to find the root directory

# the same, but only tries 3 parent folders recursively (default is 10)
rootfoldersearch.findpath('', depth=3)

# starting the search in a specific directory (as opposed to using the CWD)
rootfoldersearch.findpath('', cwd='/..')

Project details

Download files

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

Files for rootfoldersearch, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size rootfoldersearch-0.0.2-py3-none-any.whl (2.9 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size rootfoldersearch-0.0.2.tar.gz (1.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page