1
0
mirror of synced 2024-12-12 15:01:09 +01:00

[jubeat-analyser] simplify the cod ethat reads lines

This commit is contained in:
Stepland 2021-05-04 12:13:28 +02:00
parent e564229f4f
commit 02f917e6be
5 changed files with 8 additions and 16 deletions

View File

@ -324,11 +324,11 @@ class MemoParser(JubeatAnalyserParser):
def _load_memo_file(lines: List[str]) -> Song: def _load_memo_file(lines: List[str]) -> Song:
parser = MemoParser() parser = MemoParser()
for i, raw_line in enumerate(lines): for i, raw_line in enumerate(lines, start=1):
try: try:
parser.load_line(raw_line) parser.load_line(raw_line)
except Exception as e: except Exception as e:
raise SyntaxError(f"On line {i+1}\n{e}") raise SyntaxError(f"On line {i}\n{e}")
parser.finish_last_few_notes() parser.finish_last_few_notes()
metadata = Metadata( metadata = Metadata(

View File

@ -317,13 +317,11 @@ class Memo1Parser(JubeatAnalyserParser):
def _load_memo1_file(lines: List[str]) -> Song: def _load_memo1_file(lines: List[str]) -> Song:
parser = Memo1Parser() parser = Memo1Parser()
for i, raw_line in enumerate(lines): for i, raw_line in enumerate(lines, start=1):
try: try:
parser.load_line(raw_line) parser.load_line(raw_line)
except Exception as e: except Exception as e:
raise SyntaxError( raise SyntaxError(f"On line {i}\n{e}")
f"Error while parsing memo line {i} :\n" f"{type(e).__name__}: {e}"
) from None
parser.finish_last_few_notes() parser.finish_last_few_notes()
metadata = Metadata( metadata = Metadata(

View File

@ -438,13 +438,11 @@ class Memo2Parser(JubeatAnalyserParser):
def _load_memo2_file(lines: List[str]) -> Song: def _load_memo2_file(lines: List[str]) -> Song:
parser = Memo2Parser() parser = Memo2Parser()
for i, raw_line in enumerate(lines): for i, raw_line in enumerate(lines, start=1):
try: try:
parser.load_line(raw_line) parser.load_line(raw_line)
except Exception as e: except Exception as e:
raise SyntaxError( raise SyntaxError(f"On line {i}\n{e}")
f"Error while parsing memo line {i} :\n" f"{type(e).__name__}: {e}"
) from None
parser.finish_last_few_notes() parser.finish_last_few_notes()
metadata = Metadata( metadata = Metadata(

View File

@ -258,14 +258,11 @@ def load_mono_column(path: Path) -> Song:
def _load_mono_column_file(lines: List[str]) -> Song: def _load_mono_column_file(lines: List[str]) -> Song:
parser = MonoColumnParser() parser = MonoColumnParser()
for i, raw_line in enumerate(lines): for i, raw_line in enumerate(lines, start=1):
try: try:
parser.load_line(raw_line) parser.load_line(raw_line)
except Exception as e: except Exception as e:
raise SyntaxError( raise SyntaxError(f"On line {i}\n{e}")
f"Error while parsing mono column line {i} :\n"
f"{type(e).__name__}: {e}"
) from None
metadata = Metadata( metadata = Metadata(
title=parser.title, title=parser.title,

View File

@ -2,7 +2,6 @@ import unicodedata
from functools import reduce from functools import reduce
from math import gcd from math import gcd
from typing import Callable, Iterable, Optional, TypeVar from typing import Callable, Iterable, Optional, TypeVar
from numbers import Number
def single_lcm(a: int, b: int) -> int: def single_lcm(a: int, b: int) -> int: