Gradience/gradience/modules/repo.py

23 lines
614 B
Python
Raw Normal View History

2022-09-14 12:49:39 +00:00
import os
PRESET_DIR = os.path.join(
os.environ.get("XDG_CONFIG_HOME", os.environ["HOME"] + "/.config"),
"presets",
)
from .preset import Preset
from .utils import buglog, to_slug_case
class Repo:
presets = {}
def __init__(self, name):
self.name = to_slug_case(name)
self.path = os.path.join(PRESET_DIR, name)
self.presets = self.get_presets()
def get_presets(self):
presets = {}
for preset in os.listdir(self.path):
if preset.endswith(".json"):
presets[preset[:-5]] = Preset(preset[:-5], self.name)
return presets