From 868306a1d22a1a1b2a5824e79936471428fd6074 Mon Sep 17 00:00:00 2001 From: Chris Drost Date: Thu, 16 Sep 2010 17:51:06 +0200 Subject: [PATCH] For some reason not all of the changes to __init__.py are shown as having gone through :< --- __init__.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/__init__.py b/__init__.py index fd74cdb..86c15ab 100644 --- a/__init__.py +++ b/__init__.py @@ -104,21 +104,21 @@ def __repr__(self): (json.dumps(self.description), self.cipher, str(self.prompts)) @classmethod - def fromfile(c, filename, **kwargs): + def from_file(c, filename, **kwargs): #We let any IOErrors propagate to the end user. with open(filename, "r") as f: - return adso.fromstring(f.read(), **kwargs) + return adso.from_string(f.read(), **kwargs) @classmethod - def fromstring(c, source, **kwargs): + def from_string(c, source, **kwargs): try: data = json.loads(source) except ValueError: raise adsoSyntaxError('Not a JSON string', source) - return adso.fromdict(data, **kwargs) + return adso.from_dict(data, **kwargs) @classmethod - def fromdict(c, source, prompts=True, password=None): + def from_dict(c, source, prompts=True, password=None): # we do a bunch of quick checks to make sure that the data is ok if 'adso' not in source: raise adsoSyntaxError('Not an adso object', source) @@ -164,6 +164,8 @@ def fromdict(c, source, prompts=True, password=None): def to_file(self, filename): with open(filename, 'w') as f: f.write(self.to_str()) + if self.prompts: + print("Saved to '%s'." % filename) # I have made the string representation fundamental because I want the JSON # strings generated by adso to have a certain human-intuitive order which