summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/app.py35
-rw-r--r--lib/classes.py1
-rw-r--r--lib/commands.py30
-rw-r--r--lib/listcommands.py2
-rw-r--r--lib/web.py2
5 files changed, 7 insertions, 63 deletions
diff --git a/lib/app.py b/lib/app.py
index 721eec1..a8189c7 100644
--- a/lib/app.py
+++ b/lib/app.py
@@ -1,4 +1,4 @@
-from classes import YELLOW, BLACK, GREY
+from classes import BLACK, GREY
from commands import Commands
from listcommands import ListCommands
import os.path
@@ -7,35 +7,12 @@ from config import config
class Stout(Commands):
def __init__(self):
- self.name = u'\U0001F37A' #berr icon
- self.user = Stout.username()
-
- def getName(self):
- word = ' (' + self.name + ' ) '
- if self.user == '|':
- return word
- else:
- return word + GREY + '(' + self.user + ') '
-
- @staticmethod
- def username():
- """
- if users exists, return username, else return an empty string
- """
- try:
- with open(config['path'], 'rb') as fin:
- user = fin.readline().split()
- if user[0] is '':
- return ''
- else:
- return user[0].decode('utf-8')
- except Exception:
- return ''
+ self.name = u'\U0001F37A' #beer icon
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
+ if length of cmd is less than 3 and the first word isnt in list of commands, the command is INFO
else execute command into ListCommands.commands (<- list)
"""
if cmd is None:
@@ -70,13 +47,11 @@ if __name__ == '__main__':
cmd = ''
if not os.path.isfile(config['path']):
- fo = open(config['path'], 'wb')
- fo.write('|\n'.encode('utf-8'))
- fo.close()
+ open(config['path'], 'wb').close()
while cmd != 'quit':
try:
- cmd = input('>' + YELLOW + app.getName() + BLACK)
+ cmd = input('>' + GREY + ' (' + app.name + ' ) ' + BLACK)
except (EOFError, KeyboardInterrupt):
break
diff --git a/lib/classes.py b/lib/classes.py
index 33cc0ea..3a95e19 100644
--- a/lib/classes.py
+++ b/lib/classes.py
@@ -1,5 +1,4 @@
RED = '\033[91m'
-YELLOW = '\033[93m'
GREY = '\033[90m'
BLACK = '\033[0m'
BOLD = '\033[1m'
diff --git a/lib/commands.py b/lib/commands.py
index b0d07a3..ba16143 100644
--- a/lib/commands.py
+++ b/lib/commands.py
@@ -8,35 +8,7 @@ class Commands(object):
"""
this function is used for execute a command
"""
- if what == 'set':
- try:
- if cmd[1] == 'user' and cmd[2] is not None: #set name for user
- if len(cmd[2]) > 10:
- raise PersonalError('lunghezza maggiore del consetito. Max 10')
-
- if len(cmd) > ListCommands.info['set'][1]:
- raise PersonalError(GREY + 'set user' + RED + ' accetta 1 parametro')
-
-
- self.user = cmd[2]
- with open(co['path'], 'rb') as fin:
- listOld = [x.decode('utf-8') for x in fin.readlines()]
- del listOld[0]
-
- with open(co['path'], 'wb') as fout:
- fout.write((cmd[2] + '\n').encode('utf-8'))
- for i in listOld:
- fout.write((i).encode('utf-8'))
- del listOld
-
- print('Ok')
- elif cmd[1] is not ListCommands.commands['set']:
- raise KeyError
- except (IndexError, KeyError) as e:
- ListCommands.err(type(e).__name__)
- except PersonalError as e:
- ListCommands.err('personal', e.value)
- elif what == 'get':
+ if what == 'get':
try:
if len(cmd) > ListCommands.info['get'][1]:
raise PersonalError(GREY + 'get ' + RED + 'accetta 2 parametri')
diff --git a/lib/listcommands.py b/lib/listcommands.py
index 869f475..cabed64 100644
--- a/lib/listcommands.py
+++ b/lib/listcommands.py
@@ -10,7 +10,6 @@ class ListCommands(object):
'info' : '''Stout è distribuito sotto licenza MIT e pertanto è possibile farne il fork, modificarlo e distribuirlo nuovamente.
La lista dei comandi è disponibile su https://github.com/dcariotti/Stout.
Scrivere info [cmd] per avere più informazioni su un comando.''',
- 'set' : ['''Inserire un valore; accetta solo 1 parametro (user) e viene utilizzato nel modo seguente: set user NAME''', 3],
'get' : ['''Ritorna un valore e accetta i parametri todo (ritorna la lista dei todo) e ctodo (ritorna il numero dei todo).
Se utilizzato con il "flag" i, si possono visualizzare le info: get i host, get i port, get i unix_socket_path, get i db, get i user''', 3],
'add' : ['Inserisce un nuovo todo: ogni carattere dopo add sarà considerato tale',],
@@ -19,7 +18,6 @@ Se utilizzato con il "flag" i, si possono visualizzare le info: get i host, get
commands = {
'quit' : None,
- 'set' : ['user'],
'get' : ['i', ['user', 'host', 'port', 'unix_socket_path', 'db'], 'todo', 'ctodo'],
'add' : None,
'del' : None,
diff --git a/lib/web.py b/lib/web.py
index ca8e10f..dc9dc83 100644
--- a/lib/web.py
+++ b/lib/web.py
@@ -12,7 +12,7 @@ def hello():
lines = ''
if lines is not None:
- lista = [x.strip() for i, x in enumerate(lines) if i > 0]
+ lista = [x.strip() for x in lines]
else:
lista = []