Load credential file from correct path

This commit is contained in:
Joscha 2021-06-01 09:18:08 +00:00
parent f6b26f4ead
commit e1bda94329
3 changed files with 5 additions and 3 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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()