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.join('pykeen')
# Get a subdirectory (as a pathlib.Path) for ~/.data/pykeen/experiments
pykeen_experiments_directory = pystow.join('pykeen', 'experiments')
# You can go as deep as you want
pykeen_deep_directory = pystow.join('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 tabular data file from the internet and load it for usage (requires pip install pandas
):
import pystow
import pandas as pd
url = 'https://raw.githubusercontent.com/pykeen/pykeen/master/src/pykeen/datasets/nations/test.txt'
df: pd.DataFrame = pystow.ensure_csv('pykeen', 'datasets', 'nations', url=url)
Ensure a RDF file from the internet and load it for usage (requires pip install rdflib
)
import pystow
import rdflib
url = 'https://ftp.expasy.org/databases/rhea/rdf/rhea.rdf.gz'
rdf_graph: rdflib.Graph = pystow.ensure_rdf('rhea', 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.
Source Distribution
Built Distribution
File details
Details for the file pystow-0.1.2.tar.gz
.
File metadata
- Download URL: pystow-0.1.2.tar.gz
- Upload date:
- Size: 19.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1584aa49b3bcf75f9480a847e2eebf149c809c683789ef02cdd6e20e12c3f8b6 |
|
MD5 | 9c7829f313227f2549f11e00e547570e |
|
BLAKE2b-256 | a49c8b28bf2dca0d1111e7a04d82cd6502dd670cbe318c08aa2ee7c20f481e07 |
Provenance
File details
Details for the file pystow-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: pystow-0.1.2-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8c9e9a869388220f03dabe106502bf1040d628e99c11eba42e42c63468004f7 |
|
MD5 | 05d68500586c88d68f39c015366d5fbb |
|
BLAKE2b-256 | 0a728995ddd6afc76343ca079cf4c8771491622057a4998091f91c1d6e63f4e6 |