Skip to content

wearable

Classes:

BaseWearableDataExtractor

Bases: ABC, Generic[T]

Methods:

extract_wearable_data abstractmethod

extract_wearable_data(
    source: T,
) -> list[dict[str, object]]
Source code in src/hiperhealth/skills/extraction/wearable.py
@abstractmethod
def extract_wearable_data(self, source: T) -> list[dict[str, object]]:
    """
    title: Implement the wearable data extraction.
    parameters:
      source:
        type: T
        description: Value for source.
    returns:
      type: list[dict[str, object]]
      description: Return value.
    """
    raise NotImplementedError(source)

FileProcessingError

WearableDataExtractorError

Bases: Exception

WearableDataFileExtractor

WearableDataFileExtractor()

Bases: BaseWearableDataExtractor[FileInput]

Methods:

Attributes:

Source code in src/hiperhealth/skills/extraction/wearable.py
def __init__(self) -> None:
    """
    title: Initialize caching an magic-python object.
    """
    self._mimetype_cache: dict[str, MimeType] = {}
    self.mime: magic.Magic = magic.Magic(mime=True)

allowed_extensions property

allowed_extensions: list[FileExtension]

allowed_mimetypes property

allowed_mimetypes: list[MimeType]

extract_wearable_data

extract_wearable_data(
    file: FileInput,
) -> list[dict[str, object]]
Source code in src/hiperhealth/skills/extraction/wearable.py
def extract_wearable_data(
    self, file: FileInput
) -> list[dict[str, object]]:
    """
    title: Extract wearable data from file.
    parameters:
      file:
        type: FileInput
        description: Value for file.
    returns:
      type: list[dict[str, object]]
      description: Return value.
    """
    self._validate_or_raise(file)
    return self._process_file(file)

is_supported

is_supported(file: FileInput) -> bool
Source code in src/hiperhealth/skills/extraction/wearable.py
def is_supported(self, file: FileInput) -> bool:
    """
    title: Check if file is supported.
    parameters:
      file:
        type: FileInput
        description: Value for file.
    returns:
      type: bool
      description: Return value.
    """
    if isinstance(file, (tempfile.SpooledTemporaryFile, io.BytesIO)):
        # if it's a inmemory-temp file, validate it
        return self._validate_inmemory_file(file)

    if isinstance(file, Path):
        # if it's normal file, gets its extension
        return file.suffix.replace('.', '') in self.allowed_extensions

    return self._get_mime_type(file) in self.allowed_mimetypes