#!/usr/bin/env python # -*- coding: utf-8 -*- """------------------------------------------------------------------------------------------- -- IMPORTS -------------------------------------------------------------------------------------------""" """ --- PYTHON IMPORTS --- """ import os, io, shutil from os.path import dirname, abspath from configobj import ConfigObj from validate import Validator """------------------------------------------------------------------------------------------- -- PUSHBULLET CONFIG -------------------------------------------------------------------------------------------""" class PushConfig(ConfigObj): configspec = u""" [PUSHBULLET] api_key = string(default='') channel = string(default='') """ def __init__(self): super(PushConfig, self).__init__() configspecfile = os.path.join( dirname(abspath(__file__)), 'configspec.ini' ) if not os.path.exists(configspecfile): with open(configspecfile, 'w') as fd: shutil.copyfileobj(io.StringIO(PushConfig.configspec), fd) self.filename = os.path.join( dirname(abspath(__file__)), 'config.ini' ) self.configspec = configspecfile self.encoding = "UTF8" tmp = ConfigObj(self.filename, configspec=self.configspec, encoding=self.encoding) validator = Validator() tmp.validate(validator, copy=True) self.merge(tmp) if not os.path.exists(self.filename): self.write() """------------------------------------------------------------------------------------------- -- CONFIGURATION DEFINITION -------------------------------------------------------------------------------------------""" pushconfig = PushConfig()