Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixing merge

  • Loading branch information...
commit 18ca5366e2598d7e567bf55c19ed6f33a61280e0 1 parent 28e0bd2
@zachseifts authored
Showing with 39 additions and 0 deletions.
  1. +4 −0 bin/wid
  2. +35 −0 whatidid/commands.py
View
4 bin/wid
@@ -40,6 +40,10 @@ class Main(object):
command = commands.UpdateShowCommand(week=self.week)
command.run()
+ def command_todo(self):
+ command = commands.TodoCommand(message=self.message, tags=self.tags)
+ command.run()
+
def command_notfound(self):
print u'The command was not found'
exit(1);
View
35 whatidid/commands.py
@@ -157,3 +157,38 @@ def run(self):
except ValueError:
print u'There are no messages.'
+
+class TodoCommand(Command):
+ ''' Implements a class for the todo command.
+ '''
+
+ def __init__(self, **kwargs):
+ self.message = kwargs.get('message', None)
+ self.tags = kwargs.get('tags', [])
+ super(TodoCommand, self).__init__(**kwargs)
+
+ def run(self):
+ data_path = self.get_data_path('todo')
+
+ try:
+ with open(data_path, 'rb') as fp:
+ existing_data = json.load(fp)
+ except ValueError:
+ existing_data = []
+
+ if self.message:
+ m = hashlib.md5()
+ created = int(time())
+ m.update(str(created) + self.message)
+ existing_data.append({
+ 'id': m.hexdigest(),
+ 'created': created,
+ 'tags': self.tags,
+ 'message': self.message}
+ )
+ with open(data_path, 'wb') as fp:
+ data = json.dump(existing_data, fp, sort_keys=True, indent=4)
+ else:
+ print u'No todo item specified'
+ exit(1)
+

0 comments on commit 18ca536

Please sign in to comment.
Something went wrong with that request. Please try again.