diff options
author | Santo Cariotti <sancn@live.com> | 2017-08-22 11:23:28 +0200 |
---|---|---|
committer | Santo Cariotti <sancn@live.com> | 2017-08-22 11:23:28 +0200 |
commit | 182971e61b582d784025643a22f7b8de40fa2c31 (patch) | |
tree | 2a2304f2967fc74e9718eb108c56151895adb863 /lib/commands.py | |
parent | 70b6d39cfd22c35700eb7519c8bc41d6d792e1d6 (diff) |
fixed 'get todo'
Diffstat (limited to 'lib/commands.py')
-rw-r--r-- | lib/commands.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/commands.py b/lib/commands.py index 10c89fb..eaeaf98 100644 --- a/lib/commands.py +++ b/lib/commands.py @@ -19,7 +19,7 @@ class Commands(object): self.user = cmd[2] - with open('/tmp/stout', 'wb') as fout: + with open(co['path'], 'wb') as fout: fout.write(cmd[2].encode('utf-8')) print('Ok') @@ -38,7 +38,8 @@ class Commands(object): if cmd[2] == 'user': #if self.user is empty, print 'nil' if self.user != '': - print(r.get('user').decode('utf-8')) + with open(co['path'], 'rb') as fin: + print(fin.readline().decode('utf-8')) else: print('nil') elif cmd[2] not in ListCommands.commands['get'][1]: #check if the word after 'i' exists @@ -46,7 +47,16 @@ class Commands(object): else: print(co[cmd[2]]) elif cmd[1] == 'todo': - todolist = r.zrange('todo', 0, -1) + with open(co['path'], 'rb') as fout: + try: + lines = fout.readlines() + except: + lines = '' + + if lines is not None: + todolist = [x.strip() for i, x in enumerate(lines) if i > 0] + else: + todolist = [] if len(todolist) == 0: #if todo is empty print('nessun todo in lista: goditi una Stout') |