Easily pick a place to store data for your python package.
Project description
PyStow
👜 Easily pick a place to store data for your python package.
💪 Usage
Get a directory for your application.
import pystow
# Get a directory (as a pathlib.Path) for ~/.data/pykeen
pykeen_directory = pystow.get('pykeen')
# Get a subdirectory (as a pathlib.Path) for ~/.data/pykeen/experiments
pykeen_experiments_directory = pystow.get('pykeen', 'experiments')
# You can go as deep as you want
pykeen_deep_directory = pystow.get('pykeen', 'experiments', 'a', 'b', 'c')
Ensure a file from the internet is available in your application's directory:
import pystow
url = 'https://raw.githubusercontent.com/pykeen/pykeen/master/src/pykeen/datasets/nations/test.txt'
path = pystow.ensure('pykeen', 'datasets', 'nations', url=url)
Ensure a file from the internet and load it for usage:
import pystow
url = 'https://raw.githubusercontent.com/pykeen/pykeen/master/src/pykeen/datasets/nations/test.txt'
df = pystow.ensure_csv('pykeen', 'datasets', 'nations', url=url)
Also see pystow.ensure_excel()
, pystow.ensure_rdf()
, pystow.ensure_zip_df()
, and pystow.ensure_tar_df()
.
⚠️ Configuration
Data gets stored in ~/.data
by default. If you want to change the name of the directory, set the environment
variable PYSTOW_NAME
. If you want to change the default parent directory to be other than the home directory,
set PYSTOW_HOME
🚀 Installation
The most recent release can be installed from PyPI with:
$ pip install pystow
The most recent code and data can be installed directly from GitHub with:
$ pip install git+https://github.com/cthoyt/pystow.git
To install in development mode, use the following:
$ git clone git+https://github.com/cthoyt/pystow.git
$ cd pystow
$ pip install -e .
⚖️ License
The code in this package is licensed under the MIT License.
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.