skip to navigation
skip to content

stor 2.1.1

Cross-compatible API for accessing Posix and OBS storage systems

# stor

[![Build Status](](

`stor` provides a cross-compatible CLI and Python API for accessing block and
object storage. `stor` was created so you could write one piece of code to work
with local or remote files, without needing to write specialized code to handle
failure modes, retrying or temporarily system unavailability. The functional
API (i.e., `stor.copytree`, `stor.rmtree`, `stor.remove`, `stor.listdir`) will
work with the same semantics across all storage backends. This makes it really
easy to develop/test code locally with files and then take advantage of robust
and cheaper object storage when you push to remote.

View full docs for stor at .

## Quickstart

pip install stor

`stor` provides both a CLI and a Python library for manipulating Posix and OBS
with a single, cross-compatible API.

## Quickstart - CLI

usage: stor [-h] [-c CONFIG_FILE] [--version]

A command line interface for stor.

positional arguments:
list List contents using the path as a prefix.
ls List path as a directory.
cp Copy a source to a destination path.
rm Remove file at a path.
walkfiles List all files under a path that match an optional
cat Output file contents to stdout.
cd Change directory to a given OBS path.
pwd Get the present working directory of a service or all
current directories.
clear Clear current directories of a specified service.
url generate URI for path
convert-swiftstack convert swiftstack paths

optional arguments:
-h, --help show this help message and exit
File containing configuration settings.
--version Print version

You can `ls` local and remote directories

›› stor ls s3://stor-test-bucket

Copy files locally or remotely or upload from stdin

›› echo "HELLO WORLD" | stor cp - swift://AUTH_stor_test/hello_world.txt
starting upload of 1 objects
upload complete - 1/1 0:00:00 0.00 MB 0.00 MB/s
›› stor cat swift://AUTH_stor_test/hello_world.txt
›› stor cp swift://AUTH_stor_test/hello_world.txt hello_world.txt
›› stor cat hello_world.txt

## Quickstart - Python

List files in a directory, taking advantage of delimiters

>>> stor.listdir('s3://bestbucket')

List all objects in a bucket

>>> stor.list('s3://bestbucket')

Or in a local path

>>> stor.list('stor')

Read and write files from POSIX or OBS, using python file objects.

import stor
with'/my/exciting.json') as fp:
data1 = json.load(fp)

data1['read'] = True

with's3://bestbucket/exciting.json') as fp:
json.dump(data1, fp)

## Testing code that uses stor

The key design consideration of `stor` is that your code should be able to
transparently use POSIX or any object storage system to read and update files.
So, rather than use mocks, we suggest that you structure your test code to point
to local filesystem paths and restrict yourself to the functional API. E.g.,
in your prod settings, you could set `DATADIR = 's3://bestbucketever'`and when
you test, you could use `DATADIR = '/somewhat/cool/path/to/test/data'`, while
your actual code just says:

with, experiment)) as fp:
data = json.load(fp)

Easy! and no mocks required!

## Running the Tests

make test

## Contributing and Semantic Versioning

We use semantic versioning to communicate when we make API changes to the
library. See for more details on contributing to stor.

File Type Py Version Uploaded on Size
stor-2.1.1-py2.py3-none-any.whl (md5) Python Wheel 2.7 2018-03-09 112KB
stor-2.1.1.tar.gz (md5) Source 2018-03-09 67KB