summaryrefslogtreecommitdiff
path: root/src/leap/base/pluggableconfig.py
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-12-11 01:40:05 +0900
committerkali <kali@leap.se>2012-12-11 01:40:05 +0900
commit18be85f13abc6bc94a3725950ec16ad1adec0ab8 (patch)
treeb8f1e02028184bd3e7c9916a2c3ab25a22d0f794 /src/leap/base/pluggableconfig.py
parent53fa2c134ab2c96376276aa1c0ed74db0aaba218 (diff)
fetch only if not changed-since config file timestamp
Changing this now to be able to test different providers by just updating our local config file.
Diffstat (limited to 'src/leap/base/pluggableconfig.py')
-rw-r--r--src/leap/base/pluggableconfig.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/leap/base/pluggableconfig.py b/src/leap/base/pluggableconfig.py
index b8615ad8..34c1e060 100644
--- a/src/leap/base/pluggableconfig.py
+++ b/src/leap/base/pluggableconfig.py
@@ -180,6 +180,8 @@ class PluggableConfig(object):
self.adaptors = adaptors
self.types = types
self._format = format
+ self.mtime = None
+ self.dirty = False
@property
def option_dict(self):
@@ -319,6 +321,13 @@ class PluggableConfig(object):
serializable = self.prep_value(config)
adaptor.write(serializable, filename)
+ if self.mtime:
+ self.touch_mtime(filename)
+
+ def touch_mtime(self, filename):
+ mtime = self.mtime
+ os.utime(filename, (mtime, mtime))
+
def deserialize(self, string=None, fromfile=None, format=None):
"""
load configuration from a file or string
@@ -364,6 +373,12 @@ class PluggableConfig(object):
content = _try_deserialize()
return content
+ def set_dirty(self):
+ self.dirty = True
+
+ def is_dirty(self):
+ return self.dirty
+
def load(self, *args, **kwargs):
"""
load from string or file
@@ -373,6 +388,8 @@ class PluggableConfig(object):
"""
string = args[0] if args else None
fromfile = kwargs.get("fromfile", None)
+ mtime = kwargs.pop("mtime", None)
+ self.mtime = mtime
content = None
# start with defaults, so we can