spotterbase.data package

Submodules

spotterbase.data.fast_json module

Faster JSON loading.

The json module in the standard library is somewhat slow. This module provides JSON functionality from faster libraries, but falls back to the standard library if the faster libraries are not installed.

At the moment, the only supported faster library is orjson, but this might change in the future.

spotterbase.data.fast_json.dump(obj, fp: TextIO)
spotterbase.data.fast_json.dump_bytes(obj, fp: BinaryIO)
spotterbase.data.fast_json.dump_text(obj, fp: TextIO)
spotterbase.data.fast_json.load(fp: IO)
spotterbase.data.fast_json.loads(s: str)
spotterbase.data.fast_json.orjson_check() bool

spotterbase.data.locator module

class spotterbase.data.locator.CacheDir

Bases: object

cache_locator = <spotterbase.data.locator.Locator object>
classmethod get(rel_path: Path | str | None = None) Path
class spotterbase.data.locator.DataDir

Bases: object

data_locator = <spotterbase.data.locator.Locator object>
classmethod get(rel_path: Path | str) Path
class spotterbase.data.locator.Locator(name: str, description: str, default_rel_locations: list[Path | str], how_to_get: str | None = None, group: _Group | None = None)

Bases: SimpleConfigExtension

default_locations() Iterator[Path]
is_located() bool
location_opt() Path | None
require() Path
exception spotterbase.data.locator.LocatorFailedException

Bases: Exception

class spotterbase.data.locator.TmpDir

Bases: object

classmethod get(rel_path: Path | str | None = None) Path
locator = <spotterbase.data.locator.Locator object>

spotterbase.data.zipfilecache module

class spotterbase.data.zipfilecache.OpenedZipFile(filename: str, expiry: int)

Bases: ZipFile

A zip file that is currently opened in the ZipFileCache.

The expiry (an integer) indicates when the zip file may be closed. The expiry is increased when the zip file is used.

can_be_closed() bool
clean()

Remove closed files from the opened_files list

open(*args, **kwargs) IO

Opens a zip file (like zipfile.ZipFile.open)

class spotterbase.data.zipfilecache.SharedZipFileCacheExtension

Bases: ConfigExtension

prepare_argparser(argparser: ArgumentParser)
process_namespace(args: Namespace)
class spotterbase.data.zipfilecache.ZipFileCache(max_open: int = 100)

Bases: object

A cache for opened zip files

close()

Close the zip file cache

Module contents