[jhbuild] new reload method to Config



commit b04b62238d47c73a0ea3c18866e1a15cdecb1e66
Author: Frederic Peters <fpeters 0d be>
Date:   Sat May 2 00:48:45 2009 +0200

    new reload method to Config
---
 jhbuild/config.py |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/jhbuild/config.py b/jhbuild/config.py
index fc5258c..94c43c4 100644
--- a/jhbuild/config.py
+++ b/jhbuild/config.py
@@ -97,12 +97,18 @@ def addpath(envvar, path):
     os.environ[envvar] = envval
 
 class Config:
+    _orig_environ = None
+
     def __init__(self, filename=_default_jhbuildrc):
         self._config = {
             '__file__': _defaults_file,
             'addpath':  addpath,
             'prependpath':  prependpath
             }
+
+        if not self._orig_environ:
+            self._config['_orig_environ'] = os.environ.copy()
+
         env_prepends.clear()
         try:
             execfile(_defaults_file, self._config)
@@ -117,6 +123,10 @@ class Config:
         self.load()
         self.setup_env()
 
+    def reload(self):
+        os.environ = self._orig_environ.copy()
+        self.__init__(filename=self.__file__)
+
     def load(self):
         config = self._config
         try:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]