From 99d5a8a7c7f86725d772f19e007c24e9f1397740 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Thu, 20 Jul 2017 19:03:57 +0200 Subject: added docstrings --- lib/app.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'lib/app.py') diff --git a/lib/app.py b/lib/app.py index f9696cd..f994863 100644 --- a/lib/app.py +++ b/lib/app.py @@ -5,7 +5,7 @@ from listcommands import ListCommands class Stout(Commands): def __init__(self): - self.name = u'\U0001F37A' + self.name = u'\U0001F37A' #berr icon self.user = Stout.username() def getName(self): @@ -17,12 +17,21 @@ class Stout(Commands): @staticmethod def username(): + """ + if users exists, return username:0.0.0.0, else return an empty string. + there is a set into user:HOST with a variable called name + """ if r.hget('user:'+host, 'name') is not None: - return r.hget('user:'+host, 'name').decode('utf-8') + return r.hget('user:'+host, 'name').decode('utf-8') #default is a byte else: return '' def action(self, cmd): + """ + if cmd is empty, do nothing. + if length of cmd is less than 3 and the first word isn't in list of commands, the command is INFO + else execute command into ListCommands.commands (<- list) + """ if cmd is None: return None else: @@ -31,9 +40,9 @@ class Stout(Commands): if (count == 1 or count == 2) and cmd[0] not in ListCommands.commands: try: - if cmd[0] == 'info' and count == 1: + if cmd[0] == 'info' and count == 1: #general info print(ListCommands.info['info']) - elif cmd[0] == 'info' and count == 2: + elif cmd[0] == 'info' and count == 2: #info of a command print(ListCommands.info[cmd[1]][0]) else: raise KeyError @@ -56,7 +65,7 @@ if __name__ == '__main__': cmd = input('>' + Colors.yellow + app.getName() + Colors.black) except EOFError: break - + app.action(cmd) r.save() -- cgit v1.2.3-18-g5258