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