anystore.io
Generic io helpers
anystore
is built on top of
fsspec
and
provides an easy wrapper for reading and writing content from and to arbitrary
locations using the io
command:
Command-line usage
Python usage
smart_open(uri, mode=DEFAULT_MODE, **kwargs)
IO context similar to pythons built-in open()
.
Example
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uri
|
Uri
|
string or path-like key uri to open, e.g. |
required |
mode
|
str | None
|
open mode, default |
DEFAULT_MODE
|
**kwargs
|
Any
|
pass through storage-specific options |
{}
|
Yields:
Type | Description |
---|---|
IO
|
A generic file-handler like context object |
Source code in anystore/io.py
smart_read(uri, mode=DEFAULT_MODE, **kwargs)
Return content for a given file-like key directly.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uri
|
Uri
|
string or path-like key uri to open, e.g. |
required |
mode
|
str | None
|
open mode, default |
DEFAULT_MODE
|
**kwargs
|
Any
|
pass through storage-specific options |
{}
|
Returns:
Type | Description |
---|---|
AnyStr
|
|
Source code in anystore/io.py
smart_stream(uri, mode=DEFAULT_MODE, **kwargs)
Stream content line by line.
Example
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uri
|
Uri
|
string or path-like key uri to open, e.g. |
required |
mode
|
str | None
|
open mode, default |
DEFAULT_MODE
|
**kwargs
|
Any
|
pass through storage-specific options |
{}
|
Yields:
Type | Description |
---|---|
AnyStr
|
A generator of |
Source code in anystore/io.py
smart_write(uri, content, mode=DEFAULT_WRITE_MODE, **kwargs)
Write content to a given file-like key directly.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uri
|
Uri
|
string or path-like key uri to open, e.g. |
required |
content
|
bytes | str
|
|
required |
mode
|
str | None
|
open mode, default |
DEFAULT_WRITE_MODE
|
**kwargs
|
Any
|
pass through storage-specific options |
{}
|