Skip to main content

Easily pick a place to store data for your python package.

Project description

PyStow

Build status PyPI - Python Version License Documentation Status DOI

👜 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pystow-0.1.4.tar.gz (20.2 kB view details)

Uploaded Source

Built Distribution

pystow-0.1.4-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file pystow-0.1.4.tar.gz.

File metadata

  • Download URL: pystow-0.1.4.tar.gz
  • Upload date:
  • Size: 20.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

File hashes

Hashes for pystow-0.1.4.tar.gz
Algorithm Hash digest
SHA256 4ad8f87c430aeeb633bb6bb79d2e85b060d69762e1f80c39f8300dfac703dade
MD5 63df13815bb951ab489524e5e4c38409
BLAKE2b-256 487c5dd4e668a8ec2d804c2c2b95db0a1eb432f4bdb9a2d535e2287e8158b5d4

See more details on using hashes here.

Provenance

File details

Details for the file pystow-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: pystow-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

File hashes

Hashes for pystow-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 19e3824d55ee5d24f45b32a3a1dae1ca8ad27ffd2eb6b898d65ec818a71f4634
MD5 9e9e9b2c7b1807f667f5ea289f9e6cc3
BLAKE2b-256 634062ee256cd0e4263c8c93b606a7657a3eec265cc6d7874dca45d073e360bf

See more details on using hashes here.

Provenance

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