https://github.com/skylander86/uriutils
Python module for transparently handling file I/O between different storage mechanisms.
https://github.com/skylander86/uriutils
Last synced: 5 months ago
JSON representation
Python module for transparently handling file I/O between different storage mechanisms.
- Host: GitHub
- URL: https://github.com/skylander86/uriutils
- Owner: skylander86
- License: apache-2.0
- Created: 2017-07-16T08:28:47.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-11-02T09:12:03.000Z (over 7 years ago)
- Last Synced: 2024-08-08T17:17:43.525Z (almost 2 years ago)
- Language: Python
- Homepage: http://uriutils.readthedocs.io/
- Size: 211 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
uriutils 0.1
============
.. image:: https://img.shields.io/pypi/v/uriutils.svg
:target: https://pypi.python.org/pypi/uriutils
.. image:: https://readthedocs.org/projects/uriutils/badge/?version=latest
:target: http://uriutils.readthedocs.io/en/latest/?badge=latest
Working with multiple storage platforms (i.e., local filesystem, S3, Google Cloud, etc.) can be quite a hassle.
This package aims to make it transparent to the user and the developer the underlying storage system by wrapping the different protocols in a common interface.
Documentation available at http://uriutils.readthedocs.io/
Usage
-----
Example::
with uri_open('http://www.example.com', mode='r') as f:
contents = f.read()
Example with argument parser::
parser = ArgumentParser(description='Read text file from URI.')
parser.add_argument('-i', '--input', type=URIFileType('r'), metavar='', help='Input file URI.')
A = parser.parse_args()
contents = A.input.read()
print(contents)
Or, writing to a file with argument parser is as easy as::
parser = ArgumentParser(description='Write text file to URI.')
parser.add_argument('-o', '--output', type=URIFileType('w'), metavar='', help='Output file URI.')
A = parser.parse_args()
A.output.write('Hello world!\n')
A.output.close()
And you can run ``python uri.py --output s3://example-bucket/output.txt``.
For complete documentation, please see `uriutils-0.1 documentation `_.
Contribution
------------
For bugs and issues, please file them on the `issues `_ page.
Thanks!