opener
ngtools.opener
General-purpose byte stream opener.
Classes:
| Name | Description |
|---|---|
open |
General-purpose stream opener. |
chain |
Chain multiple file objects. |
Functions:
| Name | Description |
|---|---|
stringify_path |
Ensure that the input is a str or a file-like object. |
parse_protocols |
Parse protocols out of a url. |
fsopen |
Open a file with fsspec (authentify if needed). |
filesystem |
Return the fsspec filesystem corresponding to a protocol or URI. |
exists |
Check that the file or directory pointed by a URI exists. |
linc_auth_opt |
Create fsspec authentication options to access lincbrain data. |
read_json |
Read local or remote JSON file. |
write_json |
Write local or remote JSON file. |
update_json |
Update local or remote JSON file. |
parse_protocols
Bases: parsed_protocols
Parse ngtools uri.
chain
Chain multiple file objects.
open
General-purpose stream opener.
Handles:
- paths (local or url)
- opened file-objects
- anything that
fsspechandles - compressed streams
Open a file from a path or url or an opened file object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fileobj
|
path or url or file - object
|
Input file |
required |
mode
|
str
|
Opening mode |
'rb'
|
compression
|
(zip, bz2, gzip, lzma, xz, infer)
|
Compression mode. If 'infer', guess from magic number (if mode 'r') or filename (if mode 'w'). |
'zip'
|
auth
|
dict
|
Authentication options to pass to |
required |
Returns:
| Type | Description |
|---|---|
fileobj
|
Opened file |
fileobjs
instance-attribute
Additional file-like objects that may be created upon opening.
async_open
linc_auth_opt
Create fsspec authentication options to access lincbrain data.
These options should only be used when accessing data behind
neuroglancer.lincbrain.org.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
Your LINCBRAIN_API_KEY |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
opt |
dict
|
options to pass to |
dandi_auth_opt
Create fsspec authentication options to access the dandi api.
These options should only be used when accessing data behind
dandi://.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
Your DANDI_API_KEY or LINCBRAIN_API_KEY |
None
|
instance
|
(dandi, linc)
|
|
"dandi"
|
Returns:
| Name | Type | Description |
|---|---|---|
opt |
dict
|
options to pass to |
async_exists
async
Check that the file or directory pointed by a URI exists.