Afegir control visual de les lletres per a partitures
This commit is contained in:
@@ -17,6 +17,7 @@ def _sub(pattern: str, sub: str) -> Callable[[str], str]:
|
||||
def _clean_string(lyrics_str: str) -> str:
|
||||
return (
|
||||
FnChain.transform(lyrics_str) |
|
||||
# _sub(r"~", "") |
|
||||
_sub(r"\t", " ") |
|
||||
_sub(r" +", " ") |
|
||||
_sub(r" \n", "\n") |
|
||||
@@ -39,8 +40,13 @@ def get_lyric_by_id(lyric_id: int, tema_id: int | None = None) -> model.Lyrics |
|
||||
return next(iter(lyrics_dal.get_lyrics(lyric_id=lyric_id, tema_id=tema_id)), None)
|
||||
|
||||
|
||||
def update_lyric(lyric: model.Lyrics, title: str, content: str):
|
||||
lyric = dataclasses.replace(lyric, title=title.strip(), content=_clean_string(content))
|
||||
def update_lyric(lyric: model.Lyrics, title: str, content: str, max_columns: int | None = None):
|
||||
# Validate max_columns if provided
|
||||
if max_columns is not None:
|
||||
if not isinstance(max_columns, int) or max_columns < 1 or max_columns > 10:
|
||||
raise ValueError("max_columns must be an integer between 1 and 10")
|
||||
|
||||
lyric = dataclasses.replace(lyric, title=title.strip(), content=_clean_string(content), max_columns=max_columns)
|
||||
lyrics_dal.update_lyric(lyric=lyric)
|
||||
return lyric
|
||||
|
||||
|
||||
Reference in New Issue
Block a user