From 3a4dce98b09f31be4ba1c83445a309b18ce785c1 Mon Sep 17 00:00:00 2001 From: Stepland <16676308+Stepland@users.noreply.github.com> Date: Thu, 6 May 2021 15:12:12 +0200 Subject: [PATCH] Start eve support --- jubeatools/formats/__init__.py | 43 +--------------------------------- jubeatools/formats/enum.py | 9 +------ jubeatools/formats/eve/eve.py | 0 jubeatools/formats/formats.py | 42 +++++++++++++++++++++++++++++++++ jubeatools/formats/typing.py | 6 +++++ utils/bump_version.py | 4 +++- 6 files changed, 53 insertions(+), 51 deletions(-) create mode 100644 jubeatools/formats/eve/eve.py create mode 100644 jubeatools/formats/formats.py diff --git a/jubeatools/formats/__init__.py b/jubeatools/formats/__init__.py index 37d5997..1494926 100644 --- a/jubeatools/formats/__init__.py +++ b/jubeatools/formats/__init__.py @@ -1,46 +1,5 @@ """ Module containing all the load/dump code for all file formats """ - -from typing import Dict - from .enum import Format -from .jubeat_analyser import ( - dump_memo, - dump_memo1, - dump_memo2, - dump_mono_column, - load_memo, - load_memo1, - load_memo2, - load_mono_column, -) -from .memon import ( - dump_memon_0_1_0, - dump_memon_0_2_0, - dump_memon_legacy, - load_memon_0_1_0, - load_memon_0_2_0, - load_memon_legacy, -) -from .typing import Dumper, Loader - -LOADERS: Dict[Format, Loader] = { - Format.MEMON_LEGACY: load_memon_legacy, - Format.MEMON_0_1_0: load_memon_0_1_0, - Format.MEMON_0_2_0: load_memon_0_2_0, - Format.MONO_COLUMN: load_mono_column, - Format.MEMO: load_memo, - Format.MEMO_1: load_memo1, - Format.MEMO_2: load_memo2, -} - -DUMPERS: Dict[Format, Dumper] = { - Format.MEMON_LEGACY: dump_memon_legacy, - Format.MEMON_0_1_0: dump_memon_0_1_0, - Format.MEMON_0_2_0: dump_memon_0_2_0, - Format.MONO_COLUMN: dump_mono_column, - Format.MEMO: dump_memo, - Format.MEMO_1: dump_memo1, - Format.MEMO_2: dump_memo2, -} +from .formats import DUMPERS, LOADERS diff --git a/jubeatools/formats/enum.py b/jubeatools/formats/enum.py index 1604125..a0052a9 100644 --- a/jubeatools/formats/enum.py +++ b/jubeatools/formats/enum.py @@ -2,6 +2,7 @@ from enum import Enum class Format(str, Enum): + EVE = "eve" MEMON_LEGACY = "memon:legacy" MEMON_0_1_0 = "memon:v0.1.0" MEMON_0_2_0 = "memon:v0.2.0" @@ -9,11 +10,3 @@ class Format(str, Enum): MEMO = "memo" MEMO_1 = "memo1" MEMO_2 = "memo2" - - -JUBEAT_ANALYSER_FORMATS = { - Format.MONO_COLUMN, - Format.MEMO, - Format.MEMO_1, - Format.MEMO_2, -} diff --git a/jubeatools/formats/eve/eve.py b/jubeatools/formats/eve/eve.py new file mode 100644 index 0000000..e69de29 diff --git a/jubeatools/formats/formats.py b/jubeatools/formats/formats.py new file mode 100644 index 0000000..a5253b3 --- /dev/null +++ b/jubeatools/formats/formats.py @@ -0,0 +1,42 @@ +from typing import Dict + +from .enum import Format +from .jubeat_analyser import ( + dump_memo, + dump_memo1, + dump_memo2, + dump_mono_column, + load_memo, + load_memo1, + load_memo2, + load_mono_column, +) +from .memon import ( + dump_memon_0_1_0, + dump_memon_0_2_0, + dump_memon_legacy, + load_memon_0_1_0, + load_memon_0_2_0, + load_memon_legacy, +) +from .typing import Dumper, Loader + +LOADERS: Dict[Format, Loader] = { + Format.MEMON_LEGACY: load_memon_legacy, + Format.MEMON_0_1_0: load_memon_0_1_0, + Format.MEMON_0_2_0: load_memon_0_2_0, + Format.MONO_COLUMN: load_mono_column, + Format.MEMO: load_memo, + Format.MEMO_1: load_memo1, + Format.MEMO_2: load_memo2, +} + +DUMPERS: Dict[Format, Dumper] = { + Format.MEMON_LEGACY: dump_memon_legacy, + Format.MEMON_0_1_0: dump_memon_0_1_0, + Format.MEMON_0_2_0: dump_memon_0_2_0, + Format.MONO_COLUMN: dump_mono_column, + Format.MEMO: dump_memo, + Format.MEMO_1: dump_memo1, + Format.MEMO_2: dump_memo2, +} diff --git a/jubeatools/formats/typing.py b/jubeatools/formats/typing.py index 2ebfeb9..1fd1e12 100644 --- a/jubeatools/formats/typing.py +++ b/jubeatools/formats/typing.py @@ -4,7 +4,13 @@ from typing import Any, Callable, Dict, Protocol from jubeatools.song import Song +# Dumpers take a Song object and a Path hint and give back a dict that maps +# class Dumper(Protocol): + """A Dumper is a callable that takes in a Song object, a Path hint and + potential options, then gives back a dict that maps file name suggestions + to the binary content of the file""" + def __call__(self, song: Song, path: Path, **kwargs: Any) -> Dict[Path, bytes]: ... diff --git a/utils/bump_version.py b/utils/bump_version.py index 43f3aab..0c2e742 100644 --- a/utils/bump_version.py +++ b/utils/bump_version.py @@ -23,6 +23,8 @@ with open("jubeatools/version.py", mode="w") as f: if args.commit: subprocess.run(["git", "reset"]) - subprocess.run(["git", "add", "pyproject.toml", "jubeatools/version.py"], check=True) + subprocess.run( + ["git", "add", "pyproject.toml", "jubeatools/version.py"], check=True + ) subprocess.run(["git", "commit", "-m", f"Bump version to {version}"]) subprocess.run(["git", "tag", f"v{version}"])