Skip to content

Commit

Permalink
update config loader
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWii committed Jul 31, 2022
1 parent 41626b3 commit 3afe77a
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions plugins/load_config.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
import json
from dataclasses import dataclass
from typing import Dict, List, cast
from attr import dataclass
from pydantic import BaseModel

from beet import Context, Predicate, configurable
from beet import Context, configurable
from beet.core.utils import JsonDict
from bolt import Runtime

DEFAULT_MATCH = [ "config/**/*.json" ]

@dataclass
class Config:
content: JsonDict

def __getitem__(self, key: str):
return self.content[key]

def __setitem__(self, key: str, value: any):
self.content[key] = value

def get_all(self, key: str):
return [ value for cfg in self.content.values() if (value := cfg.get(key)) ]

class ConfigLoaderOptions(BaseModel):
match: List[str] = DEFAULT_MATCH

Expand Down Expand Up @@ -58,12 +43,6 @@ def merge_config(config: JsonDict, contents: Dict, id: str):
if ore.get("state"):
ore.pop("tag", None)
ore.pop("mining_level", None)
drops = ore["drops"]
if ore.get("self_drops", True):
drops.append(ore["block"]) # ores might drop themselves
for i, item in enumerate(drops):
if type(item) is str:
drops[i] = { "id": item }

if cond := contents.get("condition"):
value["condition"] = cond if type(cond) is list else [ cond ]
Expand Down

0 comments on commit 3afe77a

Please sign in to comment.