Skip to content

Commit

Permalink
For some reason not all of the changes to __init__.py are shown as ha…
Browse files Browse the repository at this point in the history
…ving gone through :<
  • Loading branch information
Chris Drost committed Sep 16, 2010
1 parent 0a19ea5 commit 868306a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions __init__.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 868306a

Please sign in to comment.