neuroglancer_scripts.file_accessor module¶
Access to a Neuroglancer pre-computed dataset on the local filesystem.
See the accessor module for a description of the
API.
- class neuroglancer_scripts.file_accessor.FileAccessor(base_dir, flat=False, gzip=True, compresslevel=9)[source]¶
Bases:
AccessorAccess a Neuroglancer pre-computed pyramid on the local file system.
- Parameters:
base_dir (str) – path to the directory containing the pyramid
flat (bool) – use a flat file layout (see On-disk file layout)
gzip (bool) – compress chunks losslessly with gzip
- can_read = True¶
This accessor is able to read data.
- can_write = True¶
This accessor is able to write data.
- fetch_chunk(key, chunk_coords)[source]¶
Fetch a chunk from the pyramid as a bytes buffer.
- Parameters:
- Returns:
the data for the chunk (uncompressed for gzip)
- Return type:
- Raises:
DataAccessError – if the chunk cannot be retrieved
NotImplementedError – if
can_readis False
- fetch_file(relative_path)[source]¶
Fetch a file relative to the precomputed pyramid’s base directory.
- Parameters:
relative_path (str) – path to the file relative to the base directory of the pyramid
- Returns:
contents of the fetched file
- Return type:
- Raises:
DataAccessError – if the requested file cannot be retrieved
NotImplementedError – if
can_readis False
- file_exists(relative_path)[source]¶
Test existence of a file relative to the base directory.
- Parameters:
relative_path (str) – path to the file relative to the base directory of the pyramid
- Returns:
True if the file exists
- Return type:
- Raises:
DataAccessError – if an error occurs when probing file existence
NotImplementedError – if
can_readis False
- store_chunk(buf, key, chunk_coords, mime_type='application/octet-stream', overwrite=True)[source]¶
Store a chunk in the pyramid from a bytes buffer.
- Parameters:
- Raises:
DataAccessError – if the chunk cannot be stored
NotImplementedError – if
can_writeis False
- store_file(relative_path, buf, mime_type='application/octet-stream', overwrite=False)[source]¶
Store a file relative to the precomputed pyramid’s base directory.
- Parameters:
- Raises:
DataAccessError – if the info file cannot be retrieved
NotImplementedError – if
can_writeis False