opener
ngtools.opener
General-purpose byte stream opener.
Classes:
| Name | Description |
|---|---|
|
General-purpose stream opener. |
|
Chain multiple file objects. |
Functions:
| Name | Description |
|---|---|
|
Ensure that the input is a str or a file-like object. |
|
Parse protocols out of a url. |
|
Open a file with fsspec (authentify if needed). |
|
Return the fsspec filesystem corresponding to a protocol or URI. |
|
Check that the file or directory pointed by a URI exists. |
|
Create fsspec authentication options to access lincbrain data. |
|
Read local or remote JSON file. |
|
Write local or remote JSON file. |
|
Update local or remote JSON file. |
parse_protocols
Bases:
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
|
|
Input file |
required |
mode
|
|
Opening mode |
'rb'
|
compression
|
(
|
Compression mode. If 'infer', guess from magic number (if mode 'r') or filename (if mode 'w'). |
'zip'
|
auth
|
|
Authentication options to pass to |
required |
Returns:
| Type | Description |
|---|---|
|
Opened file |
fileobjs
instance-attribute
Additional file-like objects that may be created upon opening.
async_open
Bases:
Async version of 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
|
|
Your LINCBRAIN_API_KEY |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
opt |
|
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
|
|
Your DANDI_API_KEY or LINCBRAIN_API_KEY |
None
|
instance
|
(
|
|
"dandi"
|
Returns:
| Name | Type | Description |
|---|---|---|
opt |
|
options to pass to |
async_exists
async
Check that the file or directory pointed by a URI exists.