diff options
| author | Nick Mathewson <nickm@torproject.org> | 2008-10-15 21:27:16 +0000 | 
|---|---|---|
| committer | Nick Mathewson <nickm@torproject.org> | 2008-10-15 21:27:16 +0000 | 
| commit | 4d39af8d89233001d607519a6d94a82d67818779 (patch) | |
| tree | 9faafbd284e0e1bc260c61a191533cf485da5528 /lib/thandy/keys.py | |
| parent | 5bdfb1ef8405a14186637785014aa32337867df5 (diff) | |
In python 2.6 and later, simplejson is built-in as json.
git-svn-id: file:///home/or/svnrepo/updater/trunk@17112 55e972cd-5a19-0410-ae62-a4d7a52db4cd
Diffstat (limited to 'lib/thandy/keys.py')
| -rw-r--r-- | lib/thandy/keys.py | 10 | 
1 files changed, 7 insertions, 3 deletions
| diff --git a/lib/thandy/keys.py b/lib/thandy/keys.py index f4bcac9..5442b26 100644 --- a/lib/thandy/keys.py +++ b/lib/thandy/keys.py @@ -11,9 +11,13 @@ import logging  import os  import struct  import sys -import simplejson  import getpass +try: +    import json +except ImportError: +    import simplejson as json +  import thandy.formats  import thandy.util @@ -380,7 +384,7 @@ class KeyStore(thandy.formats.KeyDB):          if self._encrypted:              contents = decryptSecret(contents, password) -        listOfKeys = simplejson.loads(contents) +        listOfKeys = json.loads(contents)          self._passwd = password # It worked.          if not listOfKeys.has_key('keys'):              listOfKeys['keys'] = [] @@ -409,7 +413,7 @@ class KeyStore(thandy.formats.KeyDB):                         [ key.format(private=True, includeRoles=True) for key in                           self._keys.values() ]                         } -        contents = simplejson.dumps(listOfKeys) +        contents = json.dumps(listOfKeys)          if self._encrypted:              contents = encryptSecret(contents, password)          thandy.util.replaceFile(self._fname, contents) | 
