Skip to content

Commit

Permalink
add default config file
Browse files Browse the repository at this point in the history
  • Loading branch information
cosven committed Feb 14, 2016
1 parent ab283d7 commit 38a8358
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
2 changes: 2 additions & 0 deletions feeluown/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# -*- coding: utf-8 -*-

from .config import config
11 changes: 9 additions & 2 deletions feeluown/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,22 @@
import yaml

from feeluown.constants import CONFIG_FILE_PATH
from feeluown.constants import DEFAULT_CONFIG_FILE_PATH
from feeluown.logger import LOG


class Config(MutableMapping):
def __init__(self):
self._data = dict()

def load(self, path=CONFIG_FILE_PATH):
with open(path, 'r') as f:
self._data.update(yaml.load(f))
try:
with open(path, 'r') as f:
self._data.update(yaml.load(f))
except OSError:
LOG.error('user config file not found, will load default config')
with open(DEFAULT_CONFIG_FILE_PATH, 'r') as f:
self._data.update(yaml.load(f))

def save(self, path=CONFIG_FILE_PATH):
with open(path, 'w') as f:
Expand Down
1 change: 1 addition & 0 deletions feeluown/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@
config file
"""
CONFIG_FILE_PATH = FEELUOWN_PATH + 'config.yaml'
DEFAULT_CONFIG_FILE_PATH = 'default_config.yaml'
22 changes: 22 additions & 0 deletions feeluown/default_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
theme: 'default' # not supported

player:
song_id: 0
position: 0
playback_mode: 4
state: 0

plugin:
NetEaseMusic: true
MprisEx: true
HotKey: true

lyric:
color: 'default'
background: 'default'

songs:
dirs: ['~/Music']
download: '~/Music'
...

0 comments on commit 38a8358

Please sign in to comment.