summaryrefslogtreecommitdiff
path: root/UpdateManager
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2006-04-05 14:48:32 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2006-04-05 14:48:32 +0200
commit99e04876f2b3eb1c6d9150ad0ac17ad8fc1f7e97 (patch)
tree311607e44dfa8ca9a48ba2dd82a12ae4fb467cf7 /UpdateManager
parentda4bb6a0edae19c0dc7b92fb6f5153bbb058d168 (diff)
downloadpython-apt-99e04876f2b3eb1c6d9150ad0ac17ad8fc1f7e97.tar.gz
* merged the patch from Jani for fakegconf
Diffstat (limited to 'UpdateManager')
-rw-r--r--UpdateManager/fakegconf.py61
1 files changed, 53 insertions, 8 deletions
diff --git a/UpdateManager/fakegconf.py b/UpdateManager/fakegconf.py
index fd465fa3..7e387b56 100644
--- a/UpdateManager/fakegconf.py
+++ b/UpdateManager/fakegconf.py
@@ -1,24 +1,69 @@
-# This is a class which contains stubs for the gconf methods
-# used in Update Manager. When gconf is unavailable it will
-# still work but not retain the user settings.
+# Copyright (c) 2006 Jani Monoses <jani@ubuntu.com>
+
+# This is a class which handles settings when the gconf library
+# is unavailable such as in a non-Gnome environment
+# The configuration is stored in python hash format which is sourced
+# at program start and dumped at exit
+
+import string
+import atexit
+
+CONFIG_FILE="/root/.update-manager-conf"
class FakeGconf:
+
+ def __init__(self):
+ self.config = {}
+ try:
+ #execute python file which contains the dictionary called config
+ exec open (CONFIG_FILE)
+ self.config = config
+ except:
+ pass
+ #only get the 'basename' from the gconf key
+ def keyname(self, key):
+ return string.rsplit(key, '/', 1)[-1]
+
def get_bool(self, key):
- return False
+ key = self.keyname(key)
+ return self.config.setdefault(self.keyname(key), True)
def set_bool(self, key,value):
- pass
+ key = self.keyname(key)
+ self.config[key] = value
+ # FIXME assume type is int for now
def get_pair(self, key, ta = None, tb = None):
- return [300,300]
+ key = self.keyname(key)
+ return self.config.setdefault(self.keyname(key), [400, 500])
+ # FIXME assume type is int for now
def set_pair(self, key, ta, tb, a, b):
- pass
+ key = self.keyname(key)
+ self.config[key] = [a, b]
+
+ #Save current dictionary to config file
+ def save(self):
+ file = open(CONFIG_FILE, "w")
+ data = "config = {"
+ for i in self.config:
+ data += "'"+i+"'" + ":" + str(self.config[i])+",\n"
+ data += "}"
+ file.write(data)
+ file.close()
+
VALUE_INT = ""
+fakegconf = FakeGconf()
+
def client_get_default():
- return FakeGconf()
+ return fakegconf
+
+def fakegconf_atexit():
+ fakegconf.save()
+
+atexit.register(fakegconf_atexit)