Skip to content

Commit

Permalink
utils: Use toml instead of pytoml for config
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkroot committed Jun 13, 2019
1 parent 9166da7 commit ebfe3db
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Expand Up @@ -5,11 +5,11 @@ name = "pypi"


[packages] [packages]
requests = "*" requests = "*"
pytoml = "*"
guessit = "*" guessit = "*"
pywin32 = {version = "*", sys_platform = "== 'win32'"} pywin32 = {version = "*", sys_platform = "== 'win32'"}
win10toast = {version = "*", sys_platform = "== 'win32'"} win10toast = {version = "*", sys_platform = "== 'win32'"}
notify2 = {version = "*", sys_platform = "!= 'win32'"} notify2 = {version = "*", sys_platform = "!= 'win32'"}
dbus-python = {version = "*", sys_platform = "!= 'win32'"} dbus-python = {version = "*", sys_platform = "!= 'win32'"}
toml = "*"


[dev-packages] [dev-packages]
17 changes: 9 additions & 8 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions trakt_scrobbler/utils.py
@@ -1,17 +1,24 @@
import json import json
import logging import logging
import pytoml import toml
import requests import requests
from pathlib import Path from pathlib import Path


DATA_DIR = Path('data') DATA_DIR = Path('data')
DATA_DIR.mkdir(exist_ok=True)
logger = logging.getLogger('trakt_scrobbler') logger = logging.getLogger('trakt_scrobbler')




def read_config(config_path=DATA_DIR / 'config.toml'): def read_config(config_path=DATA_DIR / 'config.toml'):
with open(config_path) as f: try:
return pytoml.load(f) with open(config_path) as f:
try:
return toml.load(f)
except toml.TomlDecodeError:
logger.error('Unable to load config.toml!')
exit(1)
except FileNotFoundError:
logger.error('config.toml not found!')
exit(1)




config = read_config() config = read_config()
Expand Down

0 comments on commit ebfe3db

Please sign in to comment.