From 02f917e6be47bb1254546e5c9671c22f3e5b204d Mon Sep 17 00:00:00 2001 From: Stepland <16676308+Stepland@users.noreply.github.com> Date: Tue, 4 May 2021 12:13:28 +0200 Subject: [PATCH] [jubeat-analyser] simplify the cod ethat reads lines --- jubeatools/formats/jubeat_analyser/memo/load.py | 4 ++-- jubeatools/formats/jubeat_analyser/memo1/load.py | 6 ++---- jubeatools/formats/jubeat_analyser/memo2/load.py | 6 ++---- jubeatools/formats/jubeat_analyser/mono_column/load.py | 7 ++----- jubeatools/utils.py | 1 - 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/jubeatools/formats/jubeat_analyser/memo/load.py b/jubeatools/formats/jubeat_analyser/memo/load.py index b49b6a8..46ac1bb 100644 --- a/jubeatools/formats/jubeat_analyser/memo/load.py +++ b/jubeatools/formats/jubeat_analyser/memo/load.py @@ -324,11 +324,11 @@ class MemoParser(JubeatAnalyserParser): def _load_memo_file(lines: List[str]) -> Song: parser = MemoParser() - for i, raw_line in enumerate(lines): + for i, raw_line in enumerate(lines, start=1): try: parser.load_line(raw_line) 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() metadata = Metadata( diff --git a/jubeatools/formats/jubeat_analyser/memo1/load.py b/jubeatools/formats/jubeat_analyser/memo1/load.py index 9364523..4479d05 100644 --- a/jubeatools/formats/jubeat_analyser/memo1/load.py +++ b/jubeatools/formats/jubeat_analyser/memo1/load.py @@ -317,13 +317,11 @@ class Memo1Parser(JubeatAnalyserParser): def _load_memo1_file(lines: List[str]) -> Song: parser = Memo1Parser() - for i, raw_line in enumerate(lines): + for i, raw_line in enumerate(lines, start=1): try: parser.load_line(raw_line) except Exception as e: - raise SyntaxError( - f"Error while parsing memo line {i} :\n" f"{type(e).__name__}: {e}" - ) from None + raise SyntaxError(f"On line {i}\n{e}") parser.finish_last_few_notes() metadata = Metadata( diff --git a/jubeatools/formats/jubeat_analyser/memo2/load.py b/jubeatools/formats/jubeat_analyser/memo2/load.py index 96252b8..b6c6cc0 100644 --- a/jubeatools/formats/jubeat_analyser/memo2/load.py +++ b/jubeatools/formats/jubeat_analyser/memo2/load.py @@ -438,13 +438,11 @@ class Memo2Parser(JubeatAnalyserParser): def _load_memo2_file(lines: List[str]) -> Song: parser = Memo2Parser() - for i, raw_line in enumerate(lines): + for i, raw_line in enumerate(lines, start=1): try: parser.load_line(raw_line) except Exception as e: - raise SyntaxError( - f"Error while parsing memo line {i} :\n" f"{type(e).__name__}: {e}" - ) from None + raise SyntaxError(f"On line {i}\n{e}") parser.finish_last_few_notes() metadata = Metadata( diff --git a/jubeatools/formats/jubeat_analyser/mono_column/load.py b/jubeatools/formats/jubeat_analyser/mono_column/load.py index ae60f6f..6e45515 100644 --- a/jubeatools/formats/jubeat_analyser/mono_column/load.py +++ b/jubeatools/formats/jubeat_analyser/mono_column/load.py @@ -258,14 +258,11 @@ def load_mono_column(path: Path) -> Song: def _load_mono_column_file(lines: List[str]) -> Song: parser = MonoColumnParser() - for i, raw_line in enumerate(lines): + for i, raw_line in enumerate(lines, start=1): try: parser.load_line(raw_line) except Exception as e: - raise SyntaxError( - f"Error while parsing mono column line {i} :\n" - f"{type(e).__name__}: {e}" - ) from None + raise SyntaxError(f"On line {i}\n{e}") metadata = Metadata( title=parser.title, diff --git a/jubeatools/utils.py b/jubeatools/utils.py index 78232a4..7ed459d 100644 --- a/jubeatools/utils.py +++ b/jubeatools/utils.py @@ -2,7 +2,6 @@ import unicodedata from functools import reduce from math import gcd from typing import Callable, Iterable, Optional, TypeVar -from numbers import Number def single_lcm(a: int, b: int) -> int: