Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

### Fixed
- Parsing of title case fields with the *strict_title_case* flag; now, when an error occurs, an `CueValidationError` is thrown instead of an `ValueError`.
- `CHANGELOG.md` markup.

## [1.0.3] - 2025-12-26

### Removed
- Index parsing stdout warning.

### Changed
- The track field type of TrackData from *int|None* to *int*, and now it is mandatory in the model.
- The track field type of `TrackData` from *int|None* to *int*, and now it is mandatory in the model.

## [1.0.2] - 2025-12-18

Expand All @@ -20,7 +24,7 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Seconds property in the FrameTime.

### Fixed
- CHANGELOG versions diff link.
- `CHANGELOG.md` versions diff link.

## [1.0.1] - 2025-11-30

Expand Down
7 changes: 5 additions & 2 deletions cuetools/parser/handlers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import Callable
from cuetools.parser.errors import CueParseError
from cuetools.parser.errors import CueParseError, CueValidationError
from cuetools.parser.lex import Token, TokenMatch
from cuetools.types.title_case import TitleCase

Expand All @@ -17,7 +17,10 @@ def title_case_handler(
match value.type:
case Token.ARG_QUOTES | Token.ARG:
if strict:
dto_strict_setter(TitleCase(value.lexeme))
try:
dto_strict_setter(TitleCase(value.lexeme))
except ValueError as e:
raise CueValidationError(line_idx, line, value.pos, value.lexeme, e)
else:
dto_setter(value.lexeme)
case _:
Expand Down
9 changes: 8 additions & 1 deletion tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging

from cuetools.models import AlbumData, RemData
from cuetools.parser.errors import CueParseError
from cuetools.parser.errors import CueParseError, CueValidationError

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -81,6 +81,13 @@ def test_line_parsing():

assert cue == AlbumData(title='The Title Of Album', performer='The Performer')

# title_case_handler() should raise CueValidation Error
cue_sheet = """TITLE "The title of album""" ''

with pytest.raises(CueValidationError) as e:
cue = cuetools.loads(cue_sheet, strict_title_case=True)
logger.debug(str(e.value))

cue_sheet = """FILE "The Title Of Album:::"!%^&" WAVE"""
with pytest.raises(CueParseError) as e:
cue = cuetools.loads(cue_sheet)
Expand Down