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:
ExceptionRaised when an audio file is invalid or corrupted.
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.file_validators.validate_wav_file_is_not_too_large(filepath)[source]
Validates that the WAV file is not larger than the maximum allowed size.
- Parameters:
filepath (Path) – The path to the file.
- Raises:
WAVTooLargeError – If the WAV file is larger than the maximum allowed size.
- 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:
Exists on disk,
Is in a supported audio format,
Is a valid, functioning audio file,
Is not too large (for WAV files).
- class transparentmeta.request.read_request.ReadRequest(**data)[source]
Bases:
BaseModelPydantic 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. 4. The file is not too large (for WAV files).
- Parameters:
value (Path) – The path to the file.
- Returns:
The validated filepath.
- Return type:
Path
- Raises:
FileNotFoundError – If the file does not exist.
UnsupportedAudioFormatError – If the file format is not supported.
InvalidAudioFileError – If the file is not a functioning audio file.
WAVTooLargeError – If the WAV file exceeds the maximum size limit.
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:
The file path exists,
The file is in a supported audio format,
The file is a valid, functioning audio file,
The file has write permissions,
The file is not too large (for WAV files),
The metadata conforms to structured validation rules.
- class transparentmeta.request.write_request.WriteRequest(**data)[source]
Bases:
BaseModelPydantic 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
-
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 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. 5. The file is not too large (for WAV files).
- Parameters:
value (Path) – The path to the file.
- Returns:
The validated file path.
- Return type:
Path
- Raises:
FileNotFoundError – If the file does not exist.
UnsupportedAudioFormatError – If the format is not supported.
InvalidAudioFileError – If the file is not a functioning audio file.
FilePermissionError – If the file is not writable.
WAVTooLargeError – If the WAV file exceeds the maximum size limit.