4 # Copyright (C) 2010 Stefanos Harhalakis
6 # This file is part of maegirls.
8 # maegirls is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # maegirls is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with maegirls. If not, see <http://www.gnu.org/licenses/>.
21 # $Id: 0.py 2265 2010-02-21 19:16:26Z v13 $
23 __version__ = "$Id: 0.py 2265 2010-02-21 19:16:26Z v13 $"
34 home=os.environ['HOME']
38 fn="%s/.maegirls" % (home, )
42 'ver': 2, # Configuration version
43 'girls': { # List of configured girls
44 'default': algo.defaults
46 'cur': "default", # Current girl
49 def upgradeConfig(cfg):
50 """ Upgrade the loaded config to the latest version """
54 for i in cfg['girls']:
56 girl['menstr']=algo.defaults['menstr']
57 girl['ovday']=algo.defaults['ovday']
67 ret=upgradeConfig(ret)
75 def sanitize_before_store(cfg0):
76 """ Ensure that Qt strings (keys) are converted to standard strings """
79 'cur': str(cfg0['cur']),
83 if cfg0.has_key('girls'):
84 for i in cfg0['girls']:
85 cfg['girls'][str(i)]=cfg0['girls'][i]
89 def storeConfig(cfg0):
91 cfg=sanitize_before_store(cfg0)
98 def storeGirl(name, dt):
103 if not cfg.has_key('girls'):
108 'cycle': dt['cycle'],
110 'ovday': dt['ovday'],
111 'menstr': dt['menstr'],
117 storeGirl(name, algo.defaults)
130 if all.has_key(name):
137 def girlExists(name):
139 if all.has_key(name):
145 def setCurrentGirl(name):
150 def getCurrentGirl():
159 def removeGirl(name):
161 if cfg['girls'].has_key(name):
162 cfg['girls'].pop(name)
167 if not girlExists(cur):
168 storeConfig(defaultcfg)
170 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: