[eve] Add --beat-snap={number}
loader option to allow aggressive rounding
cli now splits loader and dumper options and passes them on correctly Move unreleased to 1.0.0 in CHANGELOG.md
This commit is contained in:
parent
9c0850f98d
commit
97c59add43
5
.flake8
5
.flake8
@ -17,7 +17,12 @@ ignore =
|
|||||||
E731
|
E731
|
||||||
exclude =
|
exclude =
|
||||||
.git
|
.git
|
||||||
|
.hypothesis
|
||||||
|
.mypy_cache
|
||||||
|
.pytest_cache
|
||||||
|
.vscode
|
||||||
__pycache__
|
__pycache__
|
||||||
|
docs
|
||||||
dist
|
dist
|
||||||
build
|
build
|
||||||
per-file-ignores =
|
per-file-ignores =
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
# Unreleased
|
# 1.0.0
|
||||||
## Added
|
## Added
|
||||||
- [eve] 🎉 .eve support !
|
- [eve]
|
||||||
|
- 🎉 .eve support !
|
||||||
|
- Add `--beat-snap={number}` loader option to allow aggressive rounding
|
||||||
|
- Loaders can now take in arguments
|
||||||
## Fixed
|
## Fixed
|
||||||
- Fix infinite loop that would occur when choosing a deduplicated filename
|
- Fix infinite loop that would occur when choosing a deduplicated filename
|
||||||
- [jubeat-analyser] Prettier rendering of decimal values
|
- [jubeat-analyser] Prettier rendering of decimal values
|
||||||
|
24
README.md
24
README.md
@ -14,17 +14,13 @@ jubeatools ${source} ${destination} -f ${output format} (... format specific opt
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Which formats are supported
|
## Which formats are supported
|
||||||
### Memon
|
| | | input | output |
|
||||||
| | input | output |
|
|-----------------|----------------------|:-----:|:------:|
|
||||||
|--------|:-----:|:------:|
|
| memon | v0.2.0 | ✔️ | ✔️ |
|
||||||
| v0.2.0 | ✔️ | ✔️ |
|
| . | v0.1.0 | ✔️ | ✔️ |
|
||||||
| v0.1.0 | ✔️ | ✔️ |
|
| . | legacy | ✔️ | ✔️ |
|
||||||
| legacy | ✔️ | ✔️ |
|
| jubeat analyser | #memo2 | ✔️ | ✔️ |
|
||||||
|
| . | #memo1 | ✔️ | ✔️ |
|
||||||
### Jubeat Analyser
|
| . | #memo | ✔️ | ✔️ |
|
||||||
| | input | output |
|
| . | mono-column (1列形式) | ✔️ | ✔️ |
|
||||||
|----------------------|:-----:|:------:|
|
| jubeat (arcade) | .eve | ✔️ | ✔️ |
|
||||||
| #memo2 | ✔️ | ✔️ |
|
|
||||||
| #memo1 | ✔️ | ✔️ |
|
|
||||||
| #memo | ✔️ | ✔️ |
|
|
||||||
| mono-column (1列形式) | ✔️ | ✔️ |
|
|
||||||
|
0
jubeatools/cli/__init__.py
Normal file
0
jubeatools/cli/__init__.py
Normal file
@ -1,7 +1,7 @@
|
|||||||
"""Command Line Interface"""
|
"""Command Line Interface"""
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
@ -9,10 +9,18 @@ from jubeatools.formats import DUMPERS, LOADERS
|
|||||||
from jubeatools.formats.enum import Format
|
from jubeatools.formats.enum import Format
|
||||||
from jubeatools.formats.guess import guess_format
|
from jubeatools.formats.guess import guess_format
|
||||||
|
|
||||||
|
from .helpers import dumper_option, loader_option
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.argument("src", type=click.Path(exists=True, dir_okay=False))
|
@click.argument("src", type=click.Path(exists=True, dir_okay=False))
|
||||||
@click.argument("dst", type=click.Path())
|
@click.argument("dst", type=click.Path())
|
||||||
|
@click.option(
|
||||||
|
"--input-format",
|
||||||
|
"input_format",
|
||||||
|
type=click.Choice(list(f._value_ for f in LOADERS.keys())),
|
||||||
|
help="Input file format",
|
||||||
|
)
|
||||||
@click.option(
|
@click.option(
|
||||||
"-f",
|
"-f",
|
||||||
"--format",
|
"--format",
|
||||||
@ -22,16 +30,32 @@ from jubeatools.formats.guess import guess_format
|
|||||||
type=click.Choice(list(f._value_ for f in DUMPERS.keys())),
|
type=click.Choice(list(f._value_ for f in DUMPERS.keys())),
|
||||||
help="Output file format",
|
help="Output file format",
|
||||||
)
|
)
|
||||||
@click.option(
|
@dumper_option(
|
||||||
"--circlefree",
|
"--circlefree",
|
||||||
"circle_free",
|
"circle_free",
|
||||||
is_flag=True,
|
is_flag=True,
|
||||||
help="Use #circlefree=1 for jubeat analyser formats",
|
help="Use #circlefree=1 for jubeat analyser formats",
|
||||||
)
|
)
|
||||||
|
@loader_option(
|
||||||
|
"--beat-snap",
|
||||||
|
"beat_snap",
|
||||||
|
type=click.IntRange(min=1),
|
||||||
|
help=(
|
||||||
|
"For compatible input formats, snap all notes and bpm changes to "
|
||||||
|
"the nearest 1/beat_snap beat"
|
||||||
|
),
|
||||||
|
)
|
||||||
def convert(
|
def convert(
|
||||||
src: str, dst: str, output_format: Format, **kwargs: Dict[str, Any]
|
src: str,
|
||||||
|
dst: str,
|
||||||
|
input_format: Optional[Format],
|
||||||
|
output_format: Format,
|
||||||
|
loader_options: Dict[str, Any],
|
||||||
|
dumper_options: Dict[str, Any],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Convert SRC to DST using the format specified by -f"""
|
"""Convert SRC to DST using the format specified by -f"""
|
||||||
|
print(locals())
|
||||||
|
if input_format is None:
|
||||||
input_format = guess_format(Path(src))
|
input_format = guess_format(Path(src))
|
||||||
click.echo(f"Detected input file format : {input_format}")
|
click.echo(f"Detected input file format : {input_format}")
|
||||||
|
|
||||||
@ -45,8 +69,8 @@ def convert(
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
raise ValueError(f"Unsupported output format : {input_format}")
|
raise ValueError(f"Unsupported output format : {input_format}")
|
||||||
|
|
||||||
song = loader(Path(src))
|
song = loader(Path(src), **loader_options)
|
||||||
files = dumper(song, Path(dst), **kwargs)
|
files = dumper(song, Path(dst), **dumper_options)
|
||||||
for path, contents in files.items():
|
for path, contents in files.items():
|
||||||
with path.open("wb") as f:
|
with path.open("wb") as f:
|
||||||
f.write(contents)
|
f.write(contents)
|
26
jubeatools/cli/helpers.py
Normal file
26
jubeatools/cli/helpers.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
from typing import Any, Callable, Union
|
||||||
|
|
||||||
|
import click
|
||||||
|
|
||||||
|
|
||||||
|
def add_to_dict(
|
||||||
|
key: str,
|
||||||
|
) -> Callable[[click.Context, Union[click.Option, click.Parameter], Any], None]:
|
||||||
|
def add_to_key(
|
||||||
|
ctx: click.Context, param: Union[click.Option, click.Parameter], value: Any
|
||||||
|
) -> None:
|
||||||
|
ctx.params.setdefault(key, {})[param.name] = value
|
||||||
|
|
||||||
|
return add_to_key
|
||||||
|
|
||||||
|
|
||||||
|
def loader_option(*args: Any, **kwargs: Any) -> Callable:
|
||||||
|
return click.option(
|
||||||
|
*args, callback=add_to_dict("loader_options"), expose_value=False, **kwargs
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def dumper_option(*args: Any, **kwargs: Any) -> Callable:
|
||||||
|
return click.option(
|
||||||
|
*args, callback=add_to_dict("dumper_options"), expose_value=False, **kwargs
|
||||||
|
)
|
@ -30,7 +30,7 @@ flake8 = "^3.9.1"
|
|||||||
autoimport = "^0.7.0"
|
autoimport = "^0.7.0"
|
||||||
|
|
||||||
[tool.poetry.scripts]
|
[tool.poetry.scripts]
|
||||||
jubeatools = 'jubeatools.cli:convert'
|
jubeatools = 'jubeatools.cli.cli:convert'
|
||||||
|
|
||||||
[tool.isort]
|
[tool.isort]
|
||||||
multi_line_output = 3
|
multi_line_output = 3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user