Skip to main content

Forget about working directory errors

Project description

Motivation

TODO

Usage guide

You can execute the code below from any script of your project, no matter how deep it is located. The library automatically detects the project root. When from_root is called, all the folders in traceback are looked through in order to find .git directory or .project-root file (might be empty; you have to create it on your own). The first one that contains at least one of them are considered as root directory

There is a special case. If your package was installed by someone else using, for example, pip, the root directory is the one that is next to site-packages directory.

The information about from_root parameters can be found in its docstring (from_root.__doc__)

from from_root import from_root

path = from_root('a', 'b', 'c', 'file.txt', create_parent_dirs=True, pathlib=True)
with path.open('w') as file:
    file.write('from-root')

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

from-root-0.0.1.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

from_root-0.0.1-py3-none-any.whl (4.1 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