Bamboost
bamboostindexscanner

bamboost.index.scanner

Attributes

  • log=BAMBOOST_LOGGER.getChild('Scanner')
  • IDENTIFIER_PREFIX='.bamboost-collection'
  • IDENTIFIER_SEPARATOR='-'

Functions

load_collection_metadata(path, uid) -> dict[str, Any] | None

Load the metadata of a collection from its identifier file.

Arguments:
  • path:pathlib.Path

    Path to the collection directory

  • uid:str

    UID of the collection

normalize_collection_metadata(data) -> dict[str, Any]

Normalize the metadata of a collection.

This also handles backward compatibility for the "Date of creation" field.

Arguments:
  • data:typing.Mapping[str, typing.Any]

    The raw metadata dictionary.

normalize_simulation_metadata(data) -> dict[str, Any]

Normalize simulation metadata before writing to SQL.

Arguments:
  • data:typing.Mapping[str, typing.Any]
deduplicate_sequence(values, *, casefold=False) -> list[str]

Deduplicate a sequence of strings.

Arguments:
  • values:typing.Any

    The sequence of strings to deduplicate.

  • casefold:bool=False

    Whether to ignore case when deduplicating.

create_identifier_file(path, uid) -> None

Create an identifier file in the collection directory.

Arguments:
  • path:StrPath

    Path to the collection directory

  • uid:str

    UID of the collection

Arguments:
  • uid:str
validate_path(path, uid) -> bool
Arguments:
  • path:pathlib.Path
  • uid:str
find_uid_from_path(path) -> str | None
Arguments:
  • path:pathlib.Path
find_collection(uid, root_dir) -> tuple[Path, ...]

Find the collection with UID under given root_dir.

Arguments:
  • uid:str

    UID to search for

  • root_dir:pathlib.Path

    root directory for search

find_files(pattern, root_dir, exclude=None) -> tuple[Path, ...]

Locate every file matching pattern under root_dir while pruning directory names listed in exclude (exact-match on the final path part).

Returns an immutable tuple of absolute paths (str) just like the POSIX helper.

Arguments:
  • pattern:str
  • root_dir:str | os.os.PathLike
  • exclude:typing.Iterable[str] | None=None
scan_directory_for_collections(root_dir) -> tuple[tuple[str, Path], ...]

Scan the directory for collections.

Arguments:
  • root_dir:pathlib.Path

    Directory to scan for collections

Returns
tuple[tuple[str, pathlib.Path], ...]Tuple of tuples with the UID and path of the collection
_parse_datetime_value(value) -> datetime | None
Arguments:
  • value:typing.Any

On this page