Skip to content

Commit

Permalink
Move read_api_keys() outside of Config class.
Browse files Browse the repository at this point in the history
  • Loading branch information
sheriferson committed Jan 22, 2024
1 parent aade0d4 commit ea8b1ff
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/scrobble/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,23 @@
from scrobble.musicbrainz import Track


def read_api_keys(config_path: str) -> dict:
if not os.path.exists(config_path):
raise FileNotFoundError(f'.toml config file not found in {config_path}')
with open(config_path, 'rb') as config_file:
keys = tomllib.load(config_file)

return keys


@dataclass
class Config:
config_path: str = os.path.join(os.path.expanduser('~'), '.config', 'scrobble.toml')
lastfmapi: Optional[dict[str, str]] = None
pushoverapi: Optional[dict[str, str]] = None

def __post_init__(self):
keys = self.read_api_keys(self.config_path)
keys = read_api_keys(self.config_path)
self.lastfmapi = keys['lastfmapi']

if 'pushoverapi' in keys:
Expand Down

0 comments on commit ea8b1ff

Please sign in to comment.