[jhbuild/jhdebuild: 512/536] [jhdebuild] Add simple cache utils



commit 5547aea2818e30bbce05fa3829dc0ac63059613e
Author: Frederic Peters <fpeters 0d be>
Date:   Sun May 17 13:28:50 2009 +0100

    [jhdebuild] Add simple cache utils
---
 jhbuild/utils/cache.py |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/jhbuild/utils/cache.py b/jhbuild/utils/cache.py
new file mode 100644
index 0000000..7e93b16
--- /dev/null
+++ b/jhbuild/utils/cache.py
@@ -0,0 +1,17 @@
+import os
+
+BASE_DIR = os.path.expanduser('~/.jhdebuild/cache/')
+if not os.path.exists(BASE_DIR):
+    os.makedirs(BASE_DIR)
+
+def get_cached_value(key):
+    fn = os.path.join(BASE_DIR, key)
+    if os.path.exists(fn):
+        return file(fn).read()
+    return None
+
+
+def write_cached_value(key, value):
+    fn = os.path.join(BASE_DIR, key)
+    file(fn, 'w').write(value)
+



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