Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use supported_formats to determine scope #455

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions beet/library/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@
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

Expand Down Expand Up @@ -579,9 +585,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
)
# Use the pack format from the pack's supported_formats.
# Otherwise, use the pack_format itself
pack_format = 0
if self.pack:
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)
for name, item in container.items():
yield f"{overlay}{prefix}/{name}{content_type.extension}", item
Expand Down
4 changes: 2 additions & 2 deletions examples/load_overlay/beet.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 9 additions & 3 deletions examples/load_overlay/src/pack.mcmeta
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
{
Expand All @@ -15,4 +21,4 @@
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"pack": {
"pack_format": 20,
"pack_format": 50,
"description": "",
"supported_formats": [
18,
19,
20
50,
50
]
},
"overlays": {
Expand Down Expand Up @@ -37,4 +36,4 @@
}
]
}
}
}
Loading