MakePath

MakePath is a small library which aims to facilitate paths building from various locations.

MakePath is released under the LGPL v3 license.

Installation

Here is how to install MakePath from PyPI :

pip install makepath

How to use it

Here is how to make a path from root :

>>> import makepath
>>> makepath.from_root("usr", "local", "bin")
'/usr/local/bin'

You can of course make paths from other locations. See below for more information.

The makepath module

This module contains all the helper functions used to make paths.

makepath.from_root()

This function is used to make paths from root :

>>> import makepath
>>> makepath.from_root("usr", "local", "bin")
'/usr/local/bin'
makepath.from_home()

This function is used to make paths from home.

Considering the following user’s home :

>>> import os
>>> os.path.expanduser("~")
'/root'

Here is how to make a path from it :

>>> import makepath
>>> makepath.from_home(".virtualenvs", "makepath", "bin")
'/root/.virtualenvs/makepath/bin'
makepath.from_working_dir()

This function is used to make paths from the working directory.

Considering the following working directory :

>>> import os
>>> os.path.abspath('.')
'/makepath'

Here is how to make a path from it :

>>> import makepath
>>> makepath.from_working_dir("tests", "makepath", "__init__.py")
'/makepath/tests/makepath/__init__.py'
makepath.from_this_file()

This function is used to make paths from the directory containing the file from where the code is written.