add config default files

This commit is contained in:
petrucci4prez 2017-06-03 17:49:48 -04:00
parent 1a2c82da33
commit 232ead8d4b
3 changed files with 19 additions and 3 deletions

View File

@ -2,9 +2,11 @@
Presents an interface for yaml files as a dict-like object
'''
import yaml
import yaml, shutil, logging
from threading import Lock
logger = logging.getLogger(__name__)
class _ReadOnlyFile():
'''
Opens a yaml file for reading. Intended for config files.
@ -33,5 +35,13 @@ class _ReadWriteFile(_ReadOnlyFile):
with open(self._path, 'w') as f:
yaml.dump(self._dict, f, default_flow_style=False)
configFile = _ReadOnlyFile('config/pyledriver.yaml')
stateFile = _ReadWriteFile('config/state.yaml')
def _openFile(cls, path):
try:
return cls(path)
except:
logger.warn('File %s not found. Copying example', path)
shutil.copy(path + '.default', path)
return cls(path)
configFile = _openFile(_ReadOnlyFile, 'config/pyledriver.yaml')
stateFile = _openFile(_ReadWriteFile, 'config/state.yaml')

View File

@ -0,0 +1,5 @@
gmail:
passwd: bwsasfxqjbookmed
recipientList:
- natedwarshuis@gmail.com
username: natedwarshuis@gmail.com

View File

@ -0,0 +1 @@
state: disarmed