Skip to content

Commit

Permalink
fix: default pack.mcmeta should compare equal to no pack.mcmeta
Browse files Browse the repository at this point in the history
  • Loading branch information
vberlier committed Oct 9, 2023
1 parent d11477e commit 6898d99
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions beet/library/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,23 @@ def merge(self, other: Mapping[Any, SupportsMerge]) -> bool:
)
return super().merge(other)

def __eq__(self, other: Any) -> bool:
left, right = dict(self), dict(other)

left_mcmeta = left.pop("pack.mcmeta", None)
right_mcmeta = right.pop("pack.mcmeta", None)

if left != right:
return False

if left_mcmeta != right_mcmeta:
if self.pack is not None and (left_mcmeta is None or right_mcmeta is None):
default_mcmeta = type(self.pack)().mcmeta
return left_mcmeta == default_mcmeta or right_mcmeta == default_mcmeta
return False

return True


class NamespaceContainer(MatchMixin, MergeMixin, Container[str, NamespaceFileType]):
"""Container that stores one type of files in a namespace."""
Expand Down Expand Up @@ -787,6 +804,11 @@ def process(self, key: str, value: PackType) -> PackType:
value.extend_extra["pack.mcmeta"] = None
value.extend_extra["pack.png"] = None

if "pack.mcmeta" in value.extra:
del value.extra["pack.mcmeta"]
if "pack.png" in value.extra:
del value.extra["pack.png"]

if supported_formats is not None:
value.supported_formats = supported_formats

Expand Down

0 comments on commit 6898d99

Please sign in to comment.