chore: seperate share/default source logic

This commit is contained in:
Daylin Morgan 2023-05-26 22:11:06 -05:00
parent 0b26c8cb48
commit ca67431a79
Signed by: daylin
GPG key ID: C1E52E7DD81DF79F

View file

@ -51,7 +51,7 @@ from typing import (
Type, Type,
) )
__version__ = "23.5a1-dev" __version__ = "23.5a1-1-g0b26c8c-dev"
@dataclass @dataclass
@ -64,10 +64,8 @@ class Config:
srccache: Path = ( srccache: Path = (
Path(os.getenv("XDG_CACHE_HOME", Path.home() / ".cache")) / "viv" / "src" Path(os.getenv("XDG_CACHE_HOME", Path.home() / ".cache")) / "viv" / "src"
) )
srcdefault: Path = ( share: Path = (
Path(os.getenv("XDG_DATA_HOME", Path.home() / ".local" / "share")) Path(os.getenv("XDG_DATA_HOME", Path.home() / ".local" / "share")) / "viv"
/ "viv"
/ "viv.py"
) )
def __post_init__(self) -> None: def __post_init__(self) -> None:
@ -76,7 +74,8 @@ class Config:
parents=True, parents=True,
exist_ok=True, exist_ok=True,
) )
self.srcdefault.parent.mkdir(parents=True, exist_ok=True) self.share.mkdir(parents=True, exist_ok=True)
self.srcdefault = self.share / "viv.py"
c = Config() c = Config()
@ -466,12 +465,14 @@ class ViVenv:
def dump_info(self, write: bool = False) -> None: def dump_info(self, write: bool = False) -> None:
# TODO: include associated files in 'info' # TODO: include associated files in 'info'
# means it needs to be loaded first # means it needs to be loaded first
# or keep a seperate file hash in c.share?
info = { info = {
"created": str(datetime.today()), "created": str(datetime.today()),
"id": self.id, "id": self.id,
"spec": self.spec, "spec": self.spec,
"exe": self.exe, "exe": self.exe,
} }
# save metadata to json file # save metadata to json file
if write: if write:
with (self.path / "viv-info.json").open("w") as f: with (self.path / "viv-info.json").open("w") as f: