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 Readme.md is located, starting the search in the CWD.
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)

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

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

rootfoldersearch-0.0.2.tar.gz (1.7 kB view details)

Uploaded Source

Built Distribution

rootfoldersearch-0.0.2-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file rootfoldersearch-0.0.2.tar.gz.

File metadata

  • Download URL: rootfoldersearch-0.0.2.tar.gz
  • Upload date:
  • Size: 1.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.3

File hashes

Hashes for rootfoldersearch-0.0.2.tar.gz
Algorithm Hash digest
SHA256 559a6c22869f26e40c6ef3dd6c37ce05ce13c9b6d0737dafdb9e4b6dfa874498
MD5 7e91ddd3a2da40e5da9cac85f93e65dc
BLAKE2b-256 f0ceeea662ba67a47759310b1f34805917f9c93660339125be4f6c833cc9132d

See more details on using hashes here.

File details

Details for the file rootfoldersearch-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: rootfoldersearch-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.3

File hashes

Hashes for rootfoldersearch-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3da44c96d44f3431bb7f4479023c02c21b3cd62608ed09a400238ee5bc5b62fc
MD5 7e4b685c47c7a605043553c39aacf1c9
BLAKE2b-256 32acdbf88a001271ea0d41e0e3d5b08a5de401a5be3e29e13deb652379dc6fe4

See more details on using hashes here.

Supported by

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