diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/.app.py.swp | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | lib/.commands.py.swp | bin | 16384 -> 20480 bytes | |||
-rw-r--r-- | lib/app.py | 7 | ||||
-rw-r--r-- | lib/commands.py | 16 |
4 files changed, 17 insertions, 6 deletions
diff --git a/lib/.app.py.swp b/lib/.app.py.swp Binary files differnew file mode 100644 index 0000000..7aa2759 --- /dev/null +++ b/lib/.app.py.swp diff --git a/lib/.commands.py.swp b/lib/.commands.py.swp Binary files differindex 9ca6f3b..adf7a25 100644 --- a/lib/.commands.py.swp +++ b/lib/.commands.py.swp @@ -2,6 +2,7 @@ from classes import r, clear, YELLOW, BLACK, GREY from commands import Commands from listcommands import ListCommands import os.path +from config import config class Stout(Commands): @@ -22,7 +23,7 @@ class Stout(Commands): if users exists, return username, else return an empty string """ try: - with open('/tmp/stout', 'rb') as fin: + with open(config['path'], 'rb') as fin: user = fin.readline() if user == '': @@ -69,8 +70,8 @@ if __name__ == '__main__': app = Stout() cmd = '' - if not os.path.isfile('/tmp/stout'): - open('/tmp/stout', 'wb').close() + if not os.path.isfile(config['path']): + open(config['path'], 'wb').close() while cmd != 'quit': try: 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') |