Move the remaining hardcoded constants into the configuration file.
This commit is contained in:
parent
4bbf57036d
commit
d778e281ba
4 changed files with 25 additions and 30 deletions
|
@ -6,12 +6,6 @@ import tomlkit
|
|||
|
||||
from cliff.command import Command
|
||||
|
||||
THUMB_WIDTH = 1280
|
||||
THUMB_HEIGHT = 720
|
||||
FONT = "League-Spartan-Bold"
|
||||
TEXT_FILL_COLOR = "white"
|
||||
TEXT_STROKE_COLOR = "srgb(176,0,0)"
|
||||
|
||||
MIRROR = "https://youfailit.net/pub/idgames" # NYC
|
||||
|
||||
|
||||
|
@ -34,15 +28,23 @@ class Base(Command):
|
|||
"required key 'dsda' not set in config "
|
||||
+ f"{self.doom.joinpath(self.config_name)}.")
|
||||
for d in ("iwads", "pwads", "demos", "fabricate"):
|
||||
self._init_path(d)
|
||||
self._init_attr(d, d, fn=self.doom.joinpath)
|
||||
|
||||
self._init_attr("thumbnail.height", 1280)
|
||||
self._init_attr("thumbnail.width", 720)
|
||||
self._init_attr("thumbnail.font", None)
|
||||
self._init_attr("thumbnail.text_fill", "white")
|
||||
self._init_attr("thumbnail.text_stroke", "red")
|
||||
self._init_attr("fetch.mirror", "https://youfailit.net/pub/idgames")
|
||||
|
||||
def run(self, parsed_args):
|
||||
self.init_base(parsed_args)
|
||||
self.take_action(parsed_args)
|
||||
|
||||
def _init_path(self, what):
|
||||
def _init_attr(self, what, default, fn=lambda x: x):
|
||||
what = what.replace(".", "_")
|
||||
setattr(
|
||||
self, f"_{what}", self.doom.joinpath(self._config.get(what, what)))
|
||||
self, f"_{what}", fn(self._config.get(what, default)))
|
||||
setattr(
|
||||
type(self), what, property(lambda self: getattr(self, f"_{what}")))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue