transparentmeta.request package

Submodules

transparentmeta.request.exceptions module

This module defines custom exceptions for the request component.

exception transparentmeta.request.exceptions.InvalidAudioFileError(filepath, error_message)[source]

Bases: Exception

Raised when an audio file is invalid or corrupted.

__init__(filepath, error_message)[source]
exception transparentmeta.request.exceptions.NoWritePermissionsError(filepath)[source]

Bases: Exception

Raised when a file does not have write permissions.

__init__(filepath)[source]

transparentmeta.request.file_validators module

This module hosts function validators that can be used to validate requests with audio files using Pydantic models.

transparentmeta.request.file_validators.validate_audio_file_is_functioning(filepath)[source]

Validates that the audio file is a supported and correctly functioning audio file.

Parameters:

filepath (Path) – The path to the file.

Raises:

InvalidAudioFileError – If the file is not a valid supported audio file.

Returns:

The validated filepath.

Return type:

filepath (Path)

transparentmeta.request.file_validators.validate_audio_format_is_supported(filepath)[source]

Validates that the file at the given path is an audio file.

Parameters:

filepath (Path) – The path to the file.

Raises:

UnsupportedAudioFormatError – If the file is not an audio file.

Returns:

The validated filepath.

Return type:

filepath (Path)

transparentmeta.request.file_validators.validate_file_exists(filepath)[source]

Validates that a file exists at the given path.

Parameters:

filepath (Path) – The path to the file.

Raises:

FileNotFoundError – If the file does not exist.

Returns:

The validated filepath.

Return type:

filepath (Path)

transparentmeta.request.file_validators.validate_file_has_write_permissions(filepath)[source]

Validates that the file at the given path has write permissions.

Parameters:

filepath (Path) – The path to the file.

Raises:

NoWritePermissionsError – If the file does not have write permissions.

Returns:

The validated filepath.

Return type:

filepath (Path)

transparentmeta.request.read_request module

Defines the Pydantic model for handling metadata read requests.

This model is used to validate user-provided input and structure it for processing by the metadata read use case. It ensures that the given file path:

  1. Exists on disk,

  2. Is in a supported audio format,

  3. Is a valid, functioning audio file,

class transparentmeta.request.read_request.ReadRequest(**data)[source]

Bases: BaseModel

Pydantic model representing a request to read metadata from an audio file.

filepath

Path to the audio file. Validated for existence,

Type:

Path

supported format, and file integrity.
filepath: Path
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod validate_filepath(value)[source]

Validates the provided filepath using multiple file validation functions.

Ensures that: 1. The file exists. 2. The file format is supported. 3. The file is a valid audio file.

Parameters:

value (Path) – The path to the file.

Returns:

The validated filepath.

Return type:

Path

Raises:

transparentmeta.request.write_request module

Defines the Pydantic model for handling metadata write requests.

This model is used to validate user-provided input and structure it for processing by the metadata write use case. It ensures that:

  1. The file path exists,

  2. The file is in a supported audio format,

  3. The file is a valid, functioning audio file,

  4. The file has write permissions,

  5. The metadata conforms to structured validation rules.

class transparentmeta.request.write_request.WriteRequest(**data)[source]

Bases: BaseModel

Pydantic model representing a request to write metadata to an audio file.

filepath

Path to the audio file. Validated for existence, supported format, integrity, and write permissions.

Type:

Path

metadata

Metadata to be written to the audio file.

Type:

Metadata

filepath: Path
metadata: Metadata
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod validate_filepath(value)[source]

Validates the provided file path using multiple file validation functions.

Ensures that: 1. The file exists. 2. The file format is supported. 3. The file is a valid audio file. 4. The file has write permissions.

Parameters:

value (Path) – The path to the file.

Returns:

The validated file path.

Return type:

Path

Raises:

Module contents