add auth.update

This commit is contained in:
j 2010-08-24 19:08:42 +02:00
parent d31ce9e759
commit 51b4872d3e

View file

@ -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()