+ except:
+ raise
+
+ def unset(self, option):
+ if self.cache:
+ return
+
+ try:
+ filename = os.path.join(self.dir, option)
+ os.unlink(filename)
+ try:
+ os.removedirs(os.path.dirname(filename))
+ except:
+ pass
+ return True
+ except:
+ return False
+
+ def cache_it(self):
+ self.cache = {}
+ def add_to_cache(cache, dirname, fnames):
+ for file in fnames:
+ full_name = os.path.join(dirname, file)
+ if os.path.islink(full_name):
+ fnames.remove(file)
+ elif (os.path.isfile(full_name) and
+ os.access(full_name, os.R_OK)):
+ f = open(full_name, "r")
+ cache[full_name.replace(os.path.join(self.dir, ''),
+ '')] = f.read().rstrip()
+ f.close()
+ os.path.walk(self.dir, add_to_cache, self.cache)