mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Load credential file from correct path
This commit is contained in:
parent
f6b26f4ead
commit
e1bda94329
@ -16,7 +16,7 @@ AuthConstructor = Callable[[
|
||||
|
||||
AUTHENTICATORS: Dict[str, AuthConstructor] = {
|
||||
"credential-file": lambda n, s, c:
|
||||
CredentialFileAuthenticator(n, CredentialFileAuthSection(s)),
|
||||
CredentialFileAuthenticator(n, CredentialFileAuthSection(s), c),
|
||||
"keyring": lambda n, s, c:
|
||||
KeyringAuthenticator(n, KeyringAuthSection(s)),
|
||||
"simple": lambda n, s, c:
|
||||
|
@ -1,6 +1,7 @@
|
||||
from pathlib import Path
|
||||
from typing import Tuple
|
||||
|
||||
from ..config import Config
|
||||
from ..utils import fmt_real_path
|
||||
from .authenticator import Authenticator, AuthLoadError, AuthSection
|
||||
|
||||
@ -14,10 +15,10 @@ class CredentialFileAuthSection(AuthSection):
|
||||
|
||||
|
||||
class CredentialFileAuthenticator(Authenticator):
|
||||
def __init__(self, name: str, section: CredentialFileAuthSection) -> None:
|
||||
def __init__(self, name: str, section: CredentialFileAuthSection, config: Config) -> None:
|
||||
super().__init__(name)
|
||||
|
||||
path = section.path()
|
||||
path = config.default_section.working_dir() / section.path()
|
||||
try:
|
||||
with open(path) as f:
|
||||
lines = list(f)
|
||||
|
@ -69,6 +69,7 @@ class Section:
|
||||
|
||||
class DefaultSection(Section):
|
||||
def working_dir(self) -> Path:
|
||||
# TODO Change to working dir instead of manually prepending it to paths
|
||||
pathstr = self.s.get("working_dir", ".")
|
||||
return Path(pathstr).expanduser()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user