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 Readme.md is located
rootfoldersearch.findpath('Readme.md')
# the same, but using a file in a subfolder as reference to find the root directory
rootfoldersearch.findpath('/util/a-file')
# the same, but only tries 3 parent folders recursively (default is 10)
rootfoldersearch.findpath('Readme.md', depth=3)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rootfoldersearch-0.0.1.tar.gz
(1.6 kB
view hashes)
Built Distribution
Close
Hashes for rootfoldersearch-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28754a0b14fe9b344c562149b9334a6902793fe4999bdc0a8ed78dbfb8c14c42 |
|
MD5 | bc6386fe7303f4bfff89f1bfcdca664b |
|
BLAKE2b-256 | 3e368e0d29eaee5d8d96834d59794456243a7e4b4e43253724edbe5587a6ddac |