-
Notifications
You must be signed in to change notification settings - Fork 0
/
result.py
25 lines (23 loc) · 826 Bytes
/
result.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class Result(object):
def __init__(self, succeeded, **kwargs):
self.success = succeeded
self.__dict__.update(kwargs)
def __repr__(self):
if self.success:
members = [member
for member
in dir(self)
if (member != "success")
and (member[0] != "_")]
if not members:
members = ["None"]
return "Success! Members available: %s" % ", ".join(members)
else:
if any(map(self.__dict__.has_key, ("reason", "message"))):
try:
tail = self.reason
except AttributeError:
tail = self.message
else:
tail = ""
return "Failure%s" % tail