refactor: update project code
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Dict, Iterable, Optional
|
||||
from typing import Iterable
|
||||
|
||||
import tomli
|
||||
|
||||
@@ -21,16 +21,15 @@ class PresetResolverConfig:
|
||||
|
||||
|
||||
class PresetResolver:
|
||||
_source_cache: Dict[Path, dict] = {}
|
||||
_source_cache: dict[Path, dict] = {}
|
||||
|
||||
def __init__(self, basepath: Path, config: Optional[PresetResolverConfig] = None):
|
||||
def __init__(self, basepath: Path, config: PresetResolverConfig | None = None):
|
||||
self._basepath = basepath
|
||||
self._config = config or PresetResolverConfig()
|
||||
|
||||
def iter_sources(self) -> Iterable[Path]:
|
||||
if self._config.default:
|
||||
for filepath in (Path(__file__).parent / "default").iterdir():
|
||||
yield filepath
|
||||
yield from (Path(__file__).parent / "default").iterdir()
|
||||
if self._config.user:
|
||||
user_preset = Path.home() / ".preset.toml"
|
||||
if user_preset.exists():
|
||||
|
||||
Reference in New Issue
Block a user