/ Published in: Python
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
from xdg import BaseDirectory
import os
import ConfigParser
class Config(object):
def __init__(self):
self._dir=os.path.join(BaseDirectory.xdg_config_home,"freetp")
if not os.path.isdir(self._dir):
os.mkdir(self._dir)
self._file=os.path.join(self._dir,"freetp.conf")
self._cfg = ConfigParser.RawConfigParser()
if not os.path.isfile(self._file):
self._cfg.add_section('Config')
self._setMail("")
else:
self._cfg.read(self._file)
def _getMail(self):
return self._cfg.get('Config', 'mail')
def _setMail(self,v):
self._cfg.set('Config', 'mail',v)
self._save()
mail=property(_getMail,_setMail)
def _save(self):
fid=open(self._file, 'wb')
if fid:
self._cfg.write(fid)
fid.close()
Comments
 Subscribe to comments
                    Subscribe to comments
                
                