fix: refactor and fix the recipient paths parsing that was missing the remote urls
This commit is contained in:
parent
c6ac0d6043
commit
2398431a7b
3 changed files with 19 additions and 10 deletions
|
|
@ -37,7 +37,7 @@ cat << EOF > "${XDG_CONFIG_HOME:-$HOME/.config}/halig/halig.yml"
|
||||||
notebooks_root_path: ~/Documents/Notebooks
|
notebooks_root_path: ~/Documents/Notebooks
|
||||||
identity_paths:
|
identity_paths:
|
||||||
- ~/.ssh/id_ed25519
|
- ~/.ssh/id_ed25519
|
||||||
recipient_path:
|
recipient_paths:
|
||||||
- ~/.ssh/id_ed25519.pub
|
- ~/.ssh/id_ed25519.pub
|
||||||
- https://github.com/<username>.keys
|
- https://github.com/<username>.keys
|
||||||
- https://gitlab.com/<username>.keys
|
- https://gitlab.com/<username>.keys
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
__version__ = "0.2.1"
|
__version__ = "0.3.0"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import os
|
import os
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
import yaml
|
import yaml
|
||||||
|
|
@ -29,17 +30,25 @@ class Settings(BaseSettings):
|
||||||
]
|
]
|
||||||
|
|
||||||
@validator("identity_paths", "recipient_paths", pre=True)
|
@validator("identity_paths", "recipient_paths", pre=True)
|
||||||
def validate_paths(cls, v: list[str]): # noqa: N805
|
def validate_paths(cls, v: Any): # noqa: N805
|
||||||
|
if not isinstance(v, list):
|
||||||
|
v = [v]
|
||||||
new_v = []
|
new_v = []
|
||||||
for path in v:
|
for path in v:
|
||||||
if isinstance(path, str):
|
new_path = path
|
||||||
if not path.startswith("http"):
|
if isinstance(path, str) and not path.startswith("http"):
|
||||||
new_v.append(Path(path).expanduser())
|
new_path = Path(path)
|
||||||
elif isinstance(path, Path):
|
new_v.append(
|
||||||
new_v.append(path.expanduser())
|
new_path.expanduser() if isinstance(new_path, Path) else new_path,
|
||||||
else:
|
)
|
||||||
new_v.append(path)
|
return new_v
|
||||||
|
|
||||||
|
@validator("notebooks_root_path", pre=True)
|
||||||
|
def validate_notebooks_path(cls, v: Any): # noqa: N805
|
||||||
|
if isinstance(v, str):
|
||||||
|
return Path(v).expanduser()
|
||||||
|
if isinstance(v, Path):
|
||||||
|
return v.expanduser()
|
||||||
return v
|
return v
|
||||||
|
|
||||||
def load_private_keys(self) -> set[str]:
|
def load_private_keys(self) -> set[str]:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue