# Created by Matteo Rattotti on 13/03/06. # Copyright (c) 2006 Matteo Rattotti. All rights reserved. # Contact matteo.rattotti@gmail.com for any problem # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import os class prefHandler (object): def __init__(self): """ Initialize the prefHandler object """ self.username = "" self.password = "" self.proxy = "" self.timer = 0 self.sortFreq = 0 self.useMin = 0 pathFile = os.path.expanduser("~/") + "Library/Application Support/Delibar/" if not os.path.exists(pathFile): os.mkdir(pathFile) else: if os.path.exists(pathFile + "delibarUser0.8"): file = open(pathFile + "delibarUser0.8") data = file.read().split("#/#") self.username = data[0] self.password = data[1] self.proxy = data[2] self.timer = int(data[3]) self.sortFreq = int(data[4]) self.useMin = int(data[5]) file.close() def savePref(self): """ Sincronize volatile pref with local file pref """ pfile = os.path.expanduser("~/") + "Library/Application Support/Delibar/delibarUser0.8" file = open(pfile, 'w') file.write(self.username + "#/#" + self.password + "#/#" + self.proxy + "#/#" + str(self.timer) + "#/#" + str(self.sortFreq) + "#/#" + str(self.useMin)) file.close()