1
0
mirror of synced 2024-11-13 18:10:48 +01:00

[konami] Take hakus into account when choosing the end beat

This commit is contained in:
Stepland 2022-03-09 00:13:38 +01:00 committed by Stepland
parent a78d5ecc60
commit a163124473
9 changed files with 60 additions and 44 deletions

View File

@ -1,3 +1,11 @@
# v1.4.1
## Changed
- Minimum required Python version is now 3.9
## Fixed
- [eve] + [jbsq]
- Custom hakus were not taken into account when computing the time of the last
event, not anymore !
# v1.4.0
## Added
- [memon]

View File

@ -16,7 +16,8 @@ jubeatools ${source} ${destination} -f ${output format} (... format specific opt
## Which formats are supported
| | | input | output |
|-----------------|----------------------|:-----:|:------:|
| memon | v0.3.0 | ✔️ | ✔️ |
| memon | v1.0.0 | ✔️ | ✔️ |
| | v0.3.0 | ✔️ | ✔️ |
| | v0.2.0 | ✔️ | ✔️ |
| | v0.1.0 | ✔️ | ✔️ |
| | legacy | ✔️ | ✔️ |

View File

@ -13,7 +13,7 @@ Sanity checks before anything serious happens, from the repo's root :
1. Run checks <br> `$ poetry run sh ./utils/check_code.sh`
1. Make sure the unit tests pass <br> `$ poetry run pytest`
1. Fix all encountered errors
1. Rince and repeat until everythings is ok
1. Rince and repeat until everything is ok
Now that this is done you can move on to actually making a new version,
while still being in the repo's root :
@ -26,7 +26,7 @@ while still being in the repo's root :
Add `--commit` to let the script create the commit and tag for you as well
1. Inspect the result for mistakes
1. (If you did not use `--commit`)
1. (If you used `--no-commit`)
- Commit the version-bumped files
- Add a tag with the format `vX.Y.Z` (don't forget the `v` at the start)
1. Push the version bump commit and the tag

View File

@ -1,2 +0,0 @@
"""This file is here so the test code can use importlib as a portable way to
open test data in this folder"""

View File

@ -13,8 +13,9 @@ from . import data
def test_that_ommiting_beat_snap_works() -> None:
"""As pointed out by https://github.com/Stepland/jubeatools/issues/17"""
runner = CliRunner()
with runner.isolated_filesystem(), resources.path(
data, "Life Without You.eve"
data_path = resources.files(data)
with runner.isolated_filesystem(), resources.as_file(
data_path / "Life Without You.eve"
) as p:
result = runner.invoke(
convert, [str(p.resolve(strict=True)), "out.txt", "-f", "memo2"]
@ -27,7 +28,8 @@ def test_that_ommiting_beat_snap_works() -> None:
def test_that_is_flag_works_the_way_intended() -> None:
"""It's unclear to me what the default value is for an option with
is_flag=True"""
with resources.path(data, "Life Without You.eve") as p:
data_path = resources.files(data)
with resources.as_file(data_path / "Life Without You.eve") as p:
called_with_the_flag = convert.make_context(
"convert",
[str(p.resolve(strict=True)), "out.txt", "-f", "memo2", "--circlefree"],
@ -45,7 +47,10 @@ def test_that_is_flag_works_the_way_intended() -> None:
def test_that_the_merge_option_works_for_memon_files() -> None:
runner = CliRunner()
with runner.isolated_filesystem(), resources.path(data, "memon_merge") as p:
data_path = resources.files(data)
with runner.isolated_filesystem(), resources.as_file(
data_path / "memon_merge"
) as p:
result = runner.invoke(
convert,
[

View File

@ -46,7 +46,7 @@ def make_timing_events(
time_map: TimeMap,
) -> List[Event]:
bpm_events = [make_bpm_event(e, time_map) for e in timing.events]
end_beat = choose_end_beat(notes)
end_beat = choose_end_beat(notes, hakus)
end_event = make_end_event(end_beat, time_map)
measure_events = make_measure_events(end_beat, time_map)
if hakus is not None:
@ -63,10 +63,14 @@ def make_bpm_event(bpm_change: song.BPMEvent, time_map: TimeMap) -> Event:
return Event(time=ticks, command=Command.TEMPO, value=bpm_value)
def choose_end_beat(notes: List[AnyNote]) -> song.BeatsTime:
def choose_end_beat(
notes: List[AnyNote], hakus: Optional[Set[song.BeatsTime]]
) -> song.BeatsTime:
"""Leave 2 empty measures (4 beats) after the last event"""
last_note_beat = compute_last_note_beat(notes)
measure = last_note_beat - (last_note_beat % 4)
last_haku_beat = max(hakus or [], default=song.BeatsTime(0))
last_beat = max(last_haku_beat, last_note_beat)
measure = last_beat - (last_beat % 4)
return measure + song.BeatsTime(2 * 4)

60
poetry.lock generated
View File

@ -8,17 +8,17 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
[[package]]
name = "attrs"
version = "21.2.0"
version = "21.4.0"
description = "Classes Without Boilerplate"
category = "dev"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[package.extras]
dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit"]
dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit", "cloudpickle"]
docs = ["furo", "sphinx", "zope.interface", "sphinx-notfound-page"]
tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface"]
tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins"]
tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "cloudpickle"]
tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "cloudpickle"]
[[package]]
name = "autoflake"
@ -73,7 +73,7 @@ uvloop = ["uvloop (>=0.15.2)"]
[[package]]
name = "click"
version = "8.0.3"
version = "8.0.4"
description = "Composable command line interface toolkit"
category = "main"
optional = false
@ -127,7 +127,7 @@ pyflakes = ">=2.3.0,<2.4.0"
[[package]]
name = "hypothesis"
version = "6.32.1"
version = "6.39.3"
description = "A library for property-based testing"
category = "dev"
optional = false
@ -307,11 +307,11 @@ python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7"
[[package]]
name = "platformdirs"
version = "2.4.0"
version = "2.5.1"
description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"."
category = "dev"
optional = false
python-versions = ">=3.6"
python-versions = ">=3.7"
[package.extras]
docs = ["Sphinx (>=4)", "furo (>=2021.7.5b38)", "proselint (>=0.10.2)", "sphinx-autodoc-typehints (>=1.12)"]
@ -355,7 +355,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
[[package]]
name = "pyparsing"
version = "3.0.6"
version = "3.0.7"
description = "Python parsing module"
category = "dev"
optional = false
@ -478,7 +478,7 @@ test = ["pytest", "typing-extensions", "mypy"]
[[package]]
name = "types-simplejson"
version = "3.17.2"
version = "3.17.3"
description = "Typing stubs for simplejson"
category = "dev"
optional = false
@ -486,7 +486,7 @@ python-versions = "*"
[[package]]
name = "types-toml"
version = "0.10.1"
version = "0.10.4"
description = "Typing stubs for toml"
category = "dev"
optional = false
@ -494,7 +494,7 @@ python-versions = "*"
[[package]]
name = "typing-extensions"
version = "4.0.1"
version = "4.1.1"
description = "Backported and Experimental Type Hints for Python 3.6+"
category = "main"
optional = false
@ -514,8 +514,8 @@ typing-extensions = ">=3.7.4"
[metadata]
lock-version = "1.1"
python-versions = "^3.8"
content-hash = "971f32ab1478240f072615b119a1df87aebccfb26e6ee4cf013d938ff15db690"
python-versions = "^3.9"
content-hash = "bd6e600740e47d29241957cc264607263ad2f6607a54fbd125cc051edf445fe6"
[metadata.files]
atomicwrites = [
@ -523,8 +523,8 @@ atomicwrites = [
{file = "atomicwrites-1.4.0.tar.gz", hash = "sha256:ae70396ad1a434f9c7046fd2dd196fc04b12f9e91ffb859164193be8b6168a7a"},
]
attrs = [
{file = "attrs-21.2.0-py2.py3-none-any.whl", hash = "sha256:149e90d6d8ac20db7a955ad60cf0e6881a3f20d37096140088356da6c716b0b1"},
{file = "attrs-21.2.0.tar.gz", hash = "sha256:ef6aaac3ca6cd92904cdd0d83f629a15f18053ec84e6432106f7a4d04ae4f5fb"},
{file = "attrs-21.4.0-py2.py3-none-any.whl", hash = "sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4"},
{file = "attrs-21.4.0.tar.gz", hash = "sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd"},
]
autoflake = [
{file = "autoflake-1.4.tar.gz", hash = "sha256:61a353012cff6ab94ca062823d1fb2f692c4acda51c76ff83a8d77915fba51ea"},
@ -538,8 +538,8 @@ black = [
{file = "black-21.12b0.tar.gz", hash = "sha256:77b80f693a569e2e527958459634f18df9b0ba2625ba4e0c2d5da5be42e6f2b3"},
]
click = [
{file = "click-8.0.3-py3-none-any.whl", hash = "sha256:353f466495adaeb40b6b5f592f9f91cb22372351c84caeb068132442a4518ef3"},
{file = "click-8.0.3.tar.gz", hash = "sha256:410e932b050f5eed773c4cda94de75971c89cdb3155a72a0831139a79e5ecb5b"},
{file = "click-8.0.4-py3-none-any.whl", hash = "sha256:6a7a62563bbfabfda3a38f3023a1db4a35978c0abd76f6c9605ecd6554d6d9b1"},
{file = "click-8.0.4.tar.gz", hash = "sha256:8458d7b1287c5fb128c90e23381cf99dcde74beaf6c7ff6384ce84d6fe090adb"},
]
colorama = [
{file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"},
@ -557,8 +557,8 @@ flake8 = [
{file = "flake8-3.9.2.tar.gz", hash = "sha256:07528381786f2a6237b061f6e96610a4167b226cb926e2aa2b6b1d78057c576b"},
]
hypothesis = [
{file = "hypothesis-6.32.1-py3-none-any.whl", hash = "sha256:67e4fcf1da355a8996c3e1ae3e0d4c325cf318f766638a34626bf1cb906a69df"},
{file = "hypothesis-6.32.1.tar.gz", hash = "sha256:7cbd02e78807208a56dce822d39d0d0b43cc3603258d175d22c8b7875683a742"},
{file = "hypothesis-6.39.3-py3-none-any.whl", hash = "sha256:92f1c58e994e109897fd9b3c6d44eb3bd45ed95bf3c079c35f36fa0801fc5f31"},
{file = "hypothesis-6.39.3.tar.gz", hash = "sha256:f496dd053fb951b6da9611481fb4e54eeab1d37b594da5efe869083fad3ae621"},
]
iniconfig = [
{file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"},
@ -633,8 +633,8 @@ pathspec = [
{file = "pathspec-0.9.0.tar.gz", hash = "sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"},
]
platformdirs = [
{file = "platformdirs-2.4.0-py3-none-any.whl", hash = "sha256:8868bbe3c3c80d42f20156f22e7131d2fb321f5bc86a2a345375c6481a67021d"},
{file = "platformdirs-2.4.0.tar.gz", hash = "sha256:367a5e80b3d04d2428ffa76d33f124cf11e8fff2acdaa9b43d545f5c7d661ef2"},
{file = "platformdirs-2.5.1-py3-none-any.whl", hash = "sha256:bcae7cab893c2d310a711b70b24efb93334febe65f8de776ee320b517471e227"},
{file = "platformdirs-2.5.1.tar.gz", hash = "sha256:7535e70dfa32e84d4b34996ea99c5e432fa29a708d0f4e394bbcb2a8faa4f16d"},
]
pluggy = [
{file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"},
@ -653,8 +653,8 @@ pyflakes = [
{file = "pyflakes-2.3.1.tar.gz", hash = "sha256:f5bc8ecabc05bb9d291eb5203d6810b49040f6ff446a756326104746cc00c1db"},
]
pyparsing = [
{file = "pyparsing-3.0.6-py3-none-any.whl", hash = "sha256:04ff808a5b90911829c55c4e26f75fa5ca8a2f5f36aa3a51f68e27033341d3e4"},
{file = "pyparsing-3.0.6.tar.gz", hash = "sha256:d9bdec0013ef1eb5a84ab39a3b3868911598afa494f5faa038647101504e2b81"},
{file = "pyparsing-3.0.7-py3-none-any.whl", hash = "sha256:a6c06a88f252e6c322f65faf8f418b16213b51bdfaece0524c1c1bc30c63c484"},
{file = "pyparsing-3.0.7.tar.gz", hash = "sha256:18ee9022775d270c55187733956460083db60b37d0d0fb357445f3094eed3eea"},
]
pyprojroot = [
{file = "pyprojroot-0.2.0-py3-none-any.whl", hash = "sha256:741e8b4878a0d6bb6b06ec09aa05797130289e2127aa595b8f1cbadce697909f"},
@ -758,16 +758,16 @@ typeguard = [
{file = "typeguard-2.13.3.tar.gz", hash = "sha256:00edaa8da3a133674796cf5ea87d9f4b4c367d77476e185e80251cc13dfbb8c4"},
]
types-simplejson = [
{file = "types-simplejson-3.17.2.tar.gz", hash = "sha256:37ee5a1e30c69196ab52672664509dc40b9c2fed7dacdb5587701e0b768b6bfb"},
{file = "types_simplejson-3.17.2-py3-none-any.whl", hash = "sha256:a1ea755d518bb87038c7a2aaefc77d3ad43976dee5566dfd6ca5aa5758ec7a0f"},
{file = "types-simplejson-3.17.3.tar.gz", hash = "sha256:cb50282bc3319e99ed345af7343ece6e7f14d1c57b3bc41e4288a5b4a3c53253"},
{file = "types_simplejson-3.17.3-py3-none-any.whl", hash = "sha256:95c2b53e6492226461db360ee94012196c2a3ca3f06511b38902ad0ee6609f5a"},
]
types-toml = [
{file = "types-toml-0.10.1.tar.gz", hash = "sha256:5c1f8f8d57692397c8f902bf6b4d913a0952235db7db17d2908cc110e70610cb"},
{file = "types_toml-0.10.1-py3-none-any.whl", hash = "sha256:8cdfd2b7c89bed703158b042dd5cf04255dae77096db66f4a12ca0a93ccb07a5"},
{file = "types-toml-0.10.4.tar.gz", hash = "sha256:9340e7c1587715581bb13905b3af30b79fe68afaccfca377665d5e63b694129a"},
{file = "types_toml-0.10.4-py3-none-any.whl", hash = "sha256:4a9ffd47bbcec49c6fde6351a889b2c1bd3c0ef309fa0eed60dc28e58c8b9ea6"},
]
typing-extensions = [
{file = "typing_extensions-4.0.1-py3-none-any.whl", hash = "sha256:7f001e5ac290a0c0401508864c7ec868be4e701886d5b573a9528ed3973d9d3b"},
{file = "typing_extensions-4.0.1.tar.gz", hash = "sha256:4ca091dea149f945ec56afb48dae714f21e8692ef22a395223bcd328961b6a0e"},
{file = "typing_extensions-4.1.1-py3-none-any.whl", hash = "sha256:21c85e0fe4b9a155d0799430b0ad741cdce7e359660ccbd8b530613e8df88ce2"},
{file = "typing_extensions-4.1.1.tar.gz", hash = "sha256:1a9462dcc3347a79b1f1c0271fbe79e844580bb598bafa1ed208b94da3cdcd42"},
]
typing-inspect = [
{file = "typing_inspect-0.7.1-py2-none-any.whl", hash = "sha256:b1f56c0783ef0f25fb064a01be6e5407e54cf4a4bf4f3ba3fe51e0bd6dcea9e5"},

View File

@ -7,7 +7,7 @@ readme = "README.md"
repository = "https://gitlab.com/Buggyroom/jubeatools"
[tool.poetry.dependencies]
python = "^3.8"
python = "^3.9"
click = "^8.0.3"
path = "^15.1.2"
simplejson = "^3.17.0"

View File

@ -8,7 +8,7 @@ parser.add_argument(
"rule",
help="either a semver string or a bump rule, will be passed to poetry",
)
parser.add_argument("--commit", action="store_true")
parser.add_argument("--no-commit", dest="commit", action="store_false")
args = parser.parse_args()
subprocess.run(["poetry", "version", args.rule], check=True)