From 51b4872d3e2f44b18b3f5d68c20cdacd0bc775ba Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 24 Aug 2010 19:08:42 +0200 Subject: [PATCH] add auth.update --- ox/web/auth.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ox/web/auth.py b/ox/web/auth.py index 3ad7a0e..f4bb377 100644 --- a/ox/web/auth.py +++ b/ox/web/auth.py @@ -19,3 +19,16 @@ def get(key): print "please add key %s to json file '%s'" % (key, user_auth) return "" +def update(key, value): + user_auth = os.environ.get('oxAUTH', os.path.expanduser('~/.ox/auth.json')) + auth = {} + if os.path.exists(user_auth): + f = open(user_auth, "r") + data = f.read() + f.close() + auth = json.loads(data) + auth[key] = value + f = open(user_auth, "w") + f.write(json.dumps(auth, indent=2)) + f.close() +