From 913ce0679504c489a9814b73768cf65b83dce6a0 Mon Sep 17 00:00:00 2001 From: RitikShah Date: Fri, 6 Sep 2024 11:18:11 -0400 Subject: [PATCH 1/5] fix: partial impl --- beet/library/base.py | 20 +++++++++++++++---- examples/load_overlay/beet.yml | 4 ++-- examples/load_overlay/src/pack.mcmeta | 12 ++++++++--- .../{functions => function}/foo.mcfunction | 0 .../pack.mcmeta | 9 ++++----- 5 files changed, 31 insertions(+), 14 deletions(-) rename tests/snapshots/examples__build_load_overlay__0.data_pack/data/demo/{functions => function}/foo.mcfunction (100%) diff --git a/beet/library/base.py b/beet/library/base.py index 32a34958..7ca06bd1 100644 --- a/beet/library/base.py +++ b/beet/library/base.py @@ -76,7 +76,7 @@ SupportsMerge, ) from beet.core.file import File, FileOrigin, JsonFile, PngFile -from beet.core.utils import FileSystemPath, JsonDict, SupportedFormats, TextComponent +from beet.core.utils import FileSystemPath, FormatsRangeDict, JsonDict, SupportedFormats, TextComponent from .utils import list_extensions, list_origin_folders @@ -579,9 +579,21 @@ def list_files( if extend and not issubclass(content_type, extend): continue - scope = get_output_scope( - content_type.scope, self.pack.pack_format if self.pack else 0 - ) + # We grab the pack format from the pack's overlay parent if it exists + # Otherwise, grab it from the pack itself + pack_format = 0 + if self.pack: + if self.pack.overlay_parent: + if type(self.pack.overlay_parent.supported_formats) is int: + pack_format = self.pack.overlay_parent.supported_formats + elif type(self.pack.overlay_parent.supported_formats) is list[int]: + pack_format = self.pack.overlay_parent.supported_formats[1] + elif type(self.pack.overlay_parent.supported_formats) is FormatsRangeDict: + pack_format = self.pack.overlay_parent.supported_formats["max_inclusive"] + else: + pack_format = self.pack.pack_format + scope = get_output_scope(content_type.scope, pack_format) + prefix = "/".join((self.directory, namespace) + scope) for name, item in container.items(): yield f"{overlay}{prefix}/{name}{content_type.extension}", item diff --git a/examples/load_overlay/beet.yml b/examples/load_overlay/beet.yml index 0619fa3e..8045138c 100644 --- a/examples/load_overlay/beet.yml +++ b/examples/load_overlay/beet.yml @@ -1,7 +1,7 @@ data_pack: load: "src" - pack_format: 20 - supported_formats: [18, 19, 20] + pack_format: 50 + supported_formats: [50, 50] overlays: - formats: min_inclusive: 18 diff --git a/examples/load_overlay/src/pack.mcmeta b/examples/load_overlay/src/pack.mcmeta index d145ca2d..1b5afc51 100644 --- a/examples/load_overlay/src/pack.mcmeta +++ b/examples/load_overlay/src/pack.mcmeta @@ -2,11 +2,17 @@ "overlays": { "entries": [ { - "formats": {"min_inclusive": 17, "max_inclusive": 18}, + "formats": { + "min_inclusive": 17, + "max_inclusive": 18 + }, "directory": "overlay1" }, { - "formats": {"min_inclusive": 18, "max_inclusive": 19}, + "formats": { + "min_inclusive": 18, + "max_inclusive": 19 + }, "directory": "overlay2" }, { @@ -15,4 +21,4 @@ } ] } -} +} \ No newline at end of file diff --git a/tests/snapshots/examples__build_load_overlay__0.data_pack/data/demo/functions/foo.mcfunction b/tests/snapshots/examples__build_load_overlay__0.data_pack/data/demo/function/foo.mcfunction similarity index 100% rename from tests/snapshots/examples__build_load_overlay__0.data_pack/data/demo/functions/foo.mcfunction rename to tests/snapshots/examples__build_load_overlay__0.data_pack/data/demo/function/foo.mcfunction diff --git a/tests/snapshots/examples__build_load_overlay__0.data_pack/pack.mcmeta b/tests/snapshots/examples__build_load_overlay__0.data_pack/pack.mcmeta index 1aa5c97c..3a177a56 100644 --- a/tests/snapshots/examples__build_load_overlay__0.data_pack/pack.mcmeta +++ b/tests/snapshots/examples__build_load_overlay__0.data_pack/pack.mcmeta @@ -1,11 +1,10 @@ { "pack": { - "pack_format": 20, + "pack_format": 50, "description": "", "supported_formats": [ - 18, - 19, - 20 + 50, + 50 ] }, "overlays": { @@ -37,4 +36,4 @@ } ] } -} +} \ No newline at end of file From b9f449861460b380475f97729e7c2c02dae356cb Mon Sep 17 00:00:00 2001 From: Yavanni E Date: Fri, 6 Sep 2024 13:35:51 -0400 Subject: [PATCH 2/5] fix: use overlay's supported versions --- beet/library/base.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/beet/library/base.py b/beet/library/base.py index 7ca06bd1..ee6cf96a 100644 --- a/beet/library/base.py +++ b/beet/library/base.py @@ -584,12 +584,14 @@ def list_files( pack_format = 0 if self.pack: if self.pack.overlay_parent: - if type(self.pack.overlay_parent.supported_formats) is int: - pack_format = self.pack.overlay_parent.supported_formats - elif type(self.pack.overlay_parent.supported_formats) is list[int]: - pack_format = self.pack.overlay_parent.supported_formats[1] - elif type(self.pack.overlay_parent.supported_formats) is FormatsRangeDict: - pack_format = self.pack.overlay_parent.supported_formats["max_inclusive"] + supported_formats = self.pack.supported_formats + + if type(supported_formats) is int: + pack_format = supported_formats + elif type(supported_formats) is list[int]: + pack_format = supported_formats[1] + elif type(supported_formats) is FormatsRangeDict: + pack_format = supported_formats["max_inclusive"] else: pack_format = self.pack.pack_format scope = get_output_scope(content_type.scope, pack_format) From 46172437dca7aecdca92d71e6ca354e6a2775429 Mon Sep 17 00:00:00 2001 From: Misode Date: Fri, 11 Oct 2024 23:57:33 +0200 Subject: [PATCH 3/5] Fix when supported_formats doesn't exist --- beet/library/base.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/beet/library/base.py b/beet/library/base.py index ee6cf96a..4ca4741a 100644 --- a/beet/library/base.py +++ b/beet/library/base.py @@ -583,17 +583,16 @@ def list_files( # Otherwise, grab it from the pack itself pack_format = 0 if self.pack: + pack_format = self.pack.pack_format if self.pack.overlay_parent: + pack_format = self.pack.pack_format supported_formats = self.pack.supported_formats - if type(supported_formats) is int: pack_format = supported_formats elif type(supported_formats) is list[int]: pack_format = supported_formats[1] elif type(supported_formats) is FormatsRangeDict: pack_format = supported_formats["max_inclusive"] - else: - pack_format = self.pack.pack_format scope = get_output_scope(content_type.scope, pack_format) prefix = "/".join((self.directory, namespace) + scope) From a27af06d6f5808fba90a25904d88704ea2997444 Mon Sep 17 00:00:00 2001 From: Misode Date: Mon, 9 Dec 2024 02:13:39 +0100 Subject: [PATCH 4/5] Run formatter --- beet/library/base.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/beet/library/base.py b/beet/library/base.py index 4ca4741a..314b945a 100644 --- a/beet/library/base.py +++ b/beet/library/base.py @@ -76,7 +76,13 @@ SupportsMerge, ) from beet.core.file import File, FileOrigin, JsonFile, PngFile -from beet.core.utils import FileSystemPath, FormatsRangeDict, JsonDict, SupportedFormats, TextComponent +from beet.core.utils import ( + FileSystemPath, + FormatsRangeDict, + JsonDict, + SupportedFormats, + TextComponent, +) from .utils import list_extensions, list_origin_folders From 65aee3085fc92cd1cb87e605501cced273ce5e51 Mon Sep 17 00:00:00 2001 From: Misode Date: Mon, 9 Dec 2024 02:20:13 +0100 Subject: [PATCH 5/5] Simplify logic + fix comment --- beet/library/base.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/beet/library/base.py b/beet/library/base.py index 314b945a..0c2e1be0 100644 --- a/beet/library/base.py +++ b/beet/library/base.py @@ -585,20 +585,19 @@ def list_files( if extend and not issubclass(content_type, extend): continue - # We grab the pack format from the pack's overlay parent if it exists - # Otherwise, grab it from the pack itself + # Use the pack format from the pack's supported_formats. + # Otherwise, use the pack_format itself pack_format = 0 if self.pack: - pack_format = self.pack.pack_format - if self.pack.overlay_parent: + supported_formats = self.pack.supported_formats + if type(supported_formats) is int: + pack_format = supported_formats + elif type(supported_formats) is list[int]: + pack_format = supported_formats[1] + elif type(supported_formats) is FormatsRangeDict: + pack_format = supported_formats["max_inclusive"] + else: pack_format = self.pack.pack_format - supported_formats = self.pack.supported_formats - if type(supported_formats) is int: - pack_format = supported_formats - elif type(supported_formats) is list[int]: - pack_format = supported_formats[1] - elif type(supported_formats) is FormatsRangeDict: - pack_format = supported_formats["max_inclusive"] scope = get_output_scope(content_type.scope, pack_format) prefix = "/".join((self.directory, namespace) + scope)