better use of pickle
This commit is contained in:
parent
bd759262bb
commit
02659358db
|
@ -42,10 +42,8 @@ class Secrets:
|
||||||
raise exceptions.Cancelled
|
raise exceptions.Cancelled
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
pickle.dumps(self)
|
|
||||||
|
|
||||||
f = open(secrets_filename, 'w')
|
f = open(secrets_filename, 'w')
|
||||||
f.write(pickle.dumps(self))
|
pickle.dump(self, f)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def retained_secrets(self, account, bare_jid):
|
def retained_secrets(self, account, bare_jid):
|
||||||
|
@ -100,7 +98,7 @@ def load_secrets(filename):
|
||||||
f = open(filename, 'r')
|
f = open(filename, 'r')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
secrets = pickle.loads(f.read())
|
secrets = pickle.load(f)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
f.close()
|
f.close()
|
||||||
secrets = Secrets(filename)
|
secrets = Secrets(filename)
|
||||||
|
|
Loading…
Reference in New Issue