[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
|
||||
exclude =
|
||||
.git
|
||||
.hypothesis
|
||||
.mypy_cache
|
||||
.pytest_cache
|
||||
.vscode
|
||||
__pycache__
|
||||
docs
|
||||
dist
|
||||
build
|
||||
per-file-ignores =
|
||||
|
@ -1,6 +1,9 @@
|
||||
# Unreleased
|
||||
# 1.0.0
|
||||
## Added
|
||||
- [eve] 🎉 .eve support !
|
||||
- [eve]
|
||||
- 🎉 .eve support !
|
||||
- Add `--beat-snap={number}` loader option to allow aggressive rounding
|
||||
- Loaders can now take in arguments
|
||||
## Fixed
|
||||
- Fix infinite loop that would occur when choosing a deduplicated filename
|
||||
- [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
|
||||
### Memon
|
||||
| | input | output |
|
||||
|--------|:-----:|:------:|
|
||||
| v0.2.0 | ✔️ | ✔️ |
|
||||
| v0.1.0 | ✔️ | ✔️ |
|
||||
| legacy | ✔️ | ✔️ |
|
||||
|
||||
### Jubeat Analyser
|
||||
| | input | output |
|
||||
|----------------------|:-----:|:------:|
|
||||
| #memo2 | ✔️ | ✔️ |
|
||||
| #memo1 | ✔️ | ✔️ |
|
||||
| #memo | ✔️ | ✔️ |
|
||||
| mono-column (1列形式) | ✔️ | ✔️ |
|
||||
| | | input | output |
|
||||
|-----------------|----------------------|:-----:|:------:|
|
||||
| memon | v0.2.0 | ✔️ | ✔️ |
|
||||
| . | v0.1.0 | ✔️ | ✔️ |
|
||||
| . | legacy | ✔️ | ✔️ |
|
||||
| jubeat analyser | #memo2 | ✔️ | ✔️ |
|
||||
| . | #memo1 | ✔️ | ✔️ |
|
||||
| . | #memo | ✔️ | ✔️ |
|
||||
| . | mono-column (1列形式) | ✔️ | ✔️ |
|
||||
| jubeat (arcade) | .eve | ✔️ | ✔️ |
|
||||
|
0
jubeatools/cli/__init__.py
Normal file
0
jubeatools/cli/__init__.py
Normal file
@ -1,7 +1,7 @@
|
||||
"""Command Line Interface"""
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
import click
|
||||
|
||||
@ -9,10 +9,18 @@ from jubeatools.formats import DUMPERS, LOADERS
|
||||
from jubeatools.formats.enum import Format
|
||||
from jubeatools.formats.guess import guess_format
|
||||
|
||||
from .helpers import dumper_option, loader_option
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.argument("src", type=click.Path(exists=True, dir_okay=False))
|
||||
@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(
|
||||
"-f",
|
||||
"--format",
|
||||
@ -22,16 +30,32 @@ from jubeatools.formats.guess import guess_format
|
||||
type=click.Choice(list(f._value_ for f in DUMPERS.keys())),
|
||||
help="Output file format",
|
||||
)
|
||||
@click.option(
|
||||
@dumper_option(
|
||||
"--circlefree",
|
||||
"circle_free",
|
||||
is_flag=True,
|
||||
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(
|
||||
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:
|
||||
"""Convert SRC to DST using the format specified by -f"""
|
||||
print(locals())
|
||||
if input_format is None:
|
||||
input_format = guess_format(Path(src))
|
||||
click.echo(f"Detected input file format : {input_format}")
|
||||
|
||||
@ -45,8 +69,8 @@ def convert(
|
||||
except KeyError:
|
||||
raise ValueError(f"Unsupported output format : {input_format}")
|
||||
|
||||
song = loader(Path(src))
|
||||
files = dumper(song, Path(dst), **kwargs)
|
||||
song = loader(Path(src), **loader_options)
|
||||
files = dumper(song, Path(dst), **dumper_options)
|
||||
for path, contents in files.items():
|
||||
with path.open("wb") as f:
|
||||
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"
|
||||
|
||||
[tool.poetry.scripts]
|
||||
jubeatools = 'jubeatools.cli:convert'
|
||||
jubeatools = 'jubeatools.cli.cli:convert'
|
||||
|
||||
[tool.isort]
|
||||
multi_line_output = 3
|
||||
|
Loading…
x
Reference in New Issue
Block a user