26 lines
685 B
Python
26 lines
685 B
Python
|
import tomllib
|
||
|
|
||
|
from pathlib import Path
|
||
|
from typing import NamedTuple
|
||
|
|
||
|
from many_repos import errors
|
||
|
|
||
|
class Source(NamedTuple):
|
||
|
source_type: str
|
||
|
username: str
|
||
|
token: str
|
||
|
|
||
|
class Config(NamedTuple):
|
||
|
output_dir: str | Path
|
||
|
sources: dict[str, Source] | None
|
||
|
|
||
|
def load_config(config_path: str | Path) -> Config:
|
||
|
config_path = Path(config_path)
|
||
|
if not config_path.exists():
|
||
|
raise errors.ConfigNotFound(f"Config at path {config_path} not found!")
|
||
|
|
||
|
with config_path.open() as fp:
|
||
|
parsed_config = tomllib.load(fp)
|
||
|
|
||
|
return Config(output_dir="~/repos/", sources={"gitlab": Source(source_type="gitlab", username="justscreamy", token="urgay")})
|