[Boobcoming] correctbug in attends command
This commit is contained in:
parent
b5ecdd366c
commit
38402c5467
1 changed files with 7 additions and 5 deletions
|
|
@ -283,7 +283,7 @@ class Boobcoming(ReplApplication):
|
||||||
for backend, event in self.do('list_events', datetime.now(), None):
|
for backend, event in self.do('list_events', datetime.now(), None):
|
||||||
_ids.append(event.id)
|
_ids.append(event.id)
|
||||||
else:
|
else:
|
||||||
_id = args.strip().split(' ')
|
_ids = args.strip().split(' ')
|
||||||
|
|
||||||
for _id in _ids:
|
for _id in _ids:
|
||||||
event = self.get_object(_id, 'get_event')
|
event = self.get_object(_id, 'get_event')
|
||||||
|
|
@ -352,14 +352,18 @@ class Boobcoming(ReplApplication):
|
||||||
l = self.retrieve_events(args)
|
l = self.retrieve_events(args)
|
||||||
is_attending = self.booleanize(attending)
|
is_attending = self.booleanize(attending)
|
||||||
|
|
||||||
|
if not is_attending:
|
||||||
|
print >> sys.stderr, "Cannot booleanize ambiguous value '%s'" % attending
|
||||||
|
return 2
|
||||||
|
|
||||||
for event in l:
|
for event in l:
|
||||||
self.do('attends_event', event, is_attending)
|
self.do('attends_event', event, is_attending)
|
||||||
|
|
||||||
def booleanize(self, value):
|
def booleanize(self, value):
|
||||||
"""Return value as a boolean."""
|
"""Return value as a boolean."""
|
||||||
|
|
||||||
true_values = ("yes", "true", "1")
|
true_values = ("yes", "true")
|
||||||
false_values = ("no", "false", "0")
|
false_values = ("no", "false")
|
||||||
|
|
||||||
if isinstance(value, bool):
|
if isinstance(value, bool):
|
||||||
return value
|
return value
|
||||||
|
|
@ -369,5 +373,3 @@ class Boobcoming(ReplApplication):
|
||||||
|
|
||||||
elif value.lower() in false_values:
|
elif value.lower() in false_values:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
print >> sys.stderr, "Cannot booleanize ambiguous value '%s'" % value
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue