-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasks.py
More file actions
690 lines (613 loc) · 21.2 KB
/
tasks.py
File metadata and controls
690 lines (613 loc) · 21.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
# -*- coding: UTF-8 -*-
import csv
import datetime
import sys
# Lê os dados de um arquivo csv e coloca em uma lista
def readCsvFile(fileName):
data = []
with open("Files/"+fileName, "r", encoding='utf-8') as csvFile:
reader = csv.reader(csvFile, delimiter =',', quotechar = '\"')
for row in reader:
num = [x for x in row]
data.append(num)
return data
# Escreve em um arquivo csv uma lista de dados
def writeCsvFile(fileName, data):
with open("Files/"+fileName, 'w', encoding='utf-8', newline='') as csvFile:
writer = csv.writer(csvFile, delimiter=',', quotechar='\"', quoting=csv.QUOTE_MINIMAL)
writer.writerows(data)
# Lê os dados (por linha) de um arquivo e retorna uma lista com os dados
def openTxtFile(fileName):
openFile = open(fileName, "r", encoding='ansi')
newData = openFile.readlines()
openFile.close()
return newData
# Adiciona ao arquivo de texto já existente, uma nova linha
def writeTxtFile(fileName, data):
newData = openTxtFile("Files/"+fileName)
newData.append(data)
openFile = open("Files/"+fileName, "w")
openFile.writelines(newData)
openFile.close()
# Imprime as informações existente no arquivo txt de log
def showLog(fileName):
openFile = openTxtFile("Files/"+fileName)
for element in openFile:
print (element)
# Cadastra n (parâmetro) usuários informados (REMEDY)
def users():
entry = input(encodeWin("Número de usuários:", "list"))
users = []
try:
for i in range(int(entry)):
user = []
cad = "s"
while cad == "s":
entry = input("Classe:")
temp = input(encodeWin("Informação:", "list"))
if entry.lower() == "cpf":
temp = temp.replace(".", "")
temp = temp.replace("-", "")
entry = entry + ":" + temp
user.append(entry)
cad = input("Cadastrar outro atributo?(s/n)")
users.append(user)
except ValueError:
return users
return users
# Adiciona tarefas no arquivo, oriundas do REMEDY
def add(data, date):
newLine = []
newLine.append(date.strftime("%d-%m-%Y %H:%M"))
entry = input("Nome da Tarefa:")
while verifyTasks(encodeWin(newEntry(entry), "add"), data) == True:
entry = input(encodeWin("Já existe tarefa com esse nome. Informe outro nome de Tarefa:", "list"))
temp = newEntry(entry)
while temp == "false":
temp = input(encodeWin("Nome de Tarefa inválido:", "list"))
temp = newEntry(temp)
entry = temp
newLine.append(encodeWin(entry, "add"))
entry = input("Summary:")
if entry[-1::] != "." and entry[-1::] != "?" and entry[-1::] != "!" and entry != "":
entry += "."
newLine.append(encodeWin(entry.replace("\enter", "\n"), "add"))
print ("Remedy:")
temp = users()
tempAux = ""
if len(temp) > 0:
tempAux = "["
for row in temp:
tempAux += "["
for element in row:
tempAux += element + ","
tempAux = tempAux[:-1] + "]+"
if len(temp) > 0:
tempAux = tempAux[:-1] + "]"
newLine.append(encodeWin(tempAux, "add"))
entry = input("Helpdesk Voiza:")
entry = entry.replace("\includeResetSenha", includeScript("resetSenha.txt"))
entry = entry.replace("\includeSolicitarAcesso", includeScript("solicitarAcesso.txt"))
if entry[-1::] != "." and entry[-1::] != "?" and entry[-1::] != "!" and entry != "":
entry += "."
newLine.append(encodeWin(entry.replace("\enter", "\n"), "add"))
data.append(newLine)
writeCsvFile("tasks.csv", data)
# Adiciona tarefas com scopo livre
def addFree(data, date):
newLine = []
newLine.append(date.strftime("%d-%m-%Y %H:%M"))
entry = input("Nome da Tarefa:")
while verifyTasks(encodeWin(entry, "add"), data) == True:
entry = input("Ja existe tarefa com esse nome. Informe outro nome de Tarefa:")
newLine.append(encodeWin(entry, "add"))
entry = input("Informe o campo da mensagem:")
entry = entry.replace("\includeResetSenha", includeScript("resetSenha.txt"))
entry = entry.replace("\includeSolicitarAcesso", includeScript("solicitarAcesso.txt"))
if entry[-1::] != "." and entry[-1::] != "!" and entry[-1::] != "?" and entry != "":
entry += "."
newLine.append(encodeWin(entry.replace("\enter", "\n"), "add"))
data.append(newLine)
writeCsvFile("tasks.csv", data)
# Imprime todas as tarefas presentes no arquivo csv
def list(data):
c = 0
for row in data:
hour = row[0].split(":")[0].split(" ")[1]
if len(row) > 3:
index = 5
print ("-----------" + str(c+1) + "-----------\n")
print ("Data: " + row[0] + "\n")
print ("Nome da Tarefa: " + encodeWin(row[1], "list") + "\n")
if "Email" in row[1]:
print ("--Email--\n"+ encodeWin(row[2], "list") + "\n")
else:
print ("--Summary--\n"+ encodeWin(row[2], "list") + "\n")
print ("--Remedy--")
temp0 = row[3].split("+")
for e in temp0:
temp = e.split(",")
for element in temp:
element = element.replace("[", "")
element = element.replace("\'", "")
element = element.replace("]", "")
if "CPF" in element or "cpf" in element:
temp = element.split(":")
print (encodeWin(temp[0]+ ": " + maskCPF(temp[1]), "list"))
else:
print (encodeWin(element, "list"))
print ("\n--Helpdesk Voiza--" )
if (int(hour) < 13):
print ("Bom dia time,\n")
else:
print ("Boa tarde time, \n")
print (encodeWin(row[4], "list") + "\n\nAtenciosamente.")
while len(row) > index:
if isDate(row[index]) == True:
print ("\nData:"+ row[index] + "\n")
index += 1
print ("\n--Resposta--")
print (encodeWin(row[index], "list"))
index += 1
print ("\n--Helpdesk Voiza--")
if (int(hour) < 13):
print ("Bom dia time,\n")
else:
print ("Boa tarde time, \n")
print (encodeWin(row[index], "list") + "\n\nAtenciosamente.")
index+=1
else:
print ("-----------" + str(c+1) + "-----------\n")
print ("Data: " + row[0] + "\n")
print ("Nome da Tarefa: " + encodeWin(row[1], "list") + "\n")
print ("--Mensagem--\n" + encodeWin(row[2], "list") + "\n")
c += 1
if len(data) == 0:
print ("Nenhuma tarefa encontrada.")
# Remove uma tarefa do arquivo (por nome ou por índice)
def remove(data, time):
count = 0
entry = input("Informe o nome da tarefa que deseja remover:")
entry = entry.lower()
entry = encodeWin(entry, "add")
c = 0
for row in data:
if row[1].lower() == entry:
del data[c]
count += 1
c += 1
if count > 0:
writeCsvFile("tasks.csv", data)
print ("\n" + str(count) +" tarefas foram removidas com sucesso.")
removeTime(time, entry)
# Busca uma tarefa por nome ou todas as tarefas por data
def find(data):
temp = []
entry = input("Informe o nome da tarefa:")
if entry == "date":
entry = input("Informe a data(dd-mm-yyyy):")
while (validateData(entry) == False):
entry = input("Informe uma data valida (dd-mm-yyyy):")
for row in data:
if row[0].split(" ")[0] == entry:
temp.append(row)
else:
entry = entry.lower()
entry = encodeWin(entry, "add")
for row in data:
if entry in row[1].lower():
temp.append(row)
list(temp)
print ("\nForam encontrados "+str(len(temp))+ " resultados.")
# Acrescenta a resposta do cliente + o Helpdesk Voiza a uma tarefa
def edit(data, date, time):
entry = input("Informe o nome da tarefa:")
task = entry
entry = entry.lower()
entry = encodeWin(entry, "add")
flag = False
for row in data:
if row[1].lower() == entry:
flag = True
row.append(date.strftime("%d-%m-%Y %H:%M"))
entry = input("Resposta:")
if entry[-1::] != "." and entry[-1::] != "!" and entry[-1::] != "?" and entry != "":
entry += "."
row.append(encodeWin(entry.replace("\enter", "\n"), "add"))
entry = input("Helpdesk Voiza:")
entry = entry.replace("\includeResetSenha", includeScript("resetSenha.txt"))
entry = entry.replace("\includeSolicitarAcesso", includeScript("solicitarAcesso.txt"))
if entry[-1::] != "." and entry[-1::] != "!" and entry[-1::] != "?" and entry != "":
entry += "."
row.append(encodeWin(entry.replace("\enter", "\n"), "add"))
break;
if flag == True:
writeCsvFile("tasks.csv", data)
if task.upper()[0] == "I" and task.upper()[1] == "N" and task.upper()[2] == "C":
addTimeEdit(date, task.upper(), time)
else:
addTimeEdit(date, task, time)
else:
print ("\nNenhuma tarefa encontrada.")
# Permite a edição do campo mensagem (helpdesk) da tarefa e lista as tarefas com campo vazio
def editAnswer(data):
entry = input("Informe o nome da tarefa:")
entry = entry.lower()
entry = encodeWin(entry, "add")
flag = False
if entry == "":
print ("Tarefas que possuem o campo mensagem vazio:\n")
temp = []
index = []
j = 0
for row in data:
if len(row) > 3 and row[4] == "":
print (encodeWin(row[1], "list"))
temp.append(row[1])
index.append(j)
j += 1
if len(temp) > 0:
entry = input("\nDigite o nome da tarefa para alterar seu campo mensagem:")
entry = encodeWin(entry, "add")
j = 0
for element in temp:
if element.lower() == entry.lower():
flag = True
entry = input("Digite o campo mensagem:")
entry = entry.replace("\includeResetSenha", includeScript("resetSenha.txt"))
entry = entry.replace("\includeSolicitarAcesso", includeScript("solicitarAcesso.txt"))
if entry[-1::] != "." and entry[-1::] != "!" and entry[-1::] != "?" and entry != "":
entry += "."
data[index[j]][4] = encodeWin(entry.replace("\enter", "\n"), "add")
j += 1
else:
for row in data:
if row[1].lower() == entry:
if row[4] == "":
flag = True
entry = input("Digite o campo mensagem:")
entry = entry.replace("\includeResetSenha", includeScript("resetSenha.txt"))
entry = entry.replace("\includeSolicitarAcesso", includeScript("solicitarAcesso.txt"))
if entry[-1::] != "." and entry[-1::] != "!" and entry[-1::] != "?" and entry != "":
entry += "."
row[4] = encodeWin(entry.replace("\enter", "\n"), "add")
if flag == True:
writeCsvFile("tasks.csv", data)
else:
print ("\nNenhuma tarefa encontrada.")
# Aloca uma quantidade de horas para uma tarefa
def timeAdd(time, data):
temp = []
flag = False
entry = input("Informe a data (dd-mm-yyyy):")
while (validateData(entry) == False):
entry = input("Informe uma data valida (dd-mm-yyyy):")
temp.append(entry)
entry = input("Informe o nome da tarefa:")
entry = encodeWin(entry, "add")
while flag == False:
for row in data:
if entry.lower() == row[1].lower() or entry == "exit":
flag = True
break
if flag == False:
entry = input("Informe um nome de tarefa correto:")
entry = encodeWin(entry, "add")
if entry != "exit":
temp.append(entry)
entry = input("Informe a quantidade de horas:")
temp.append(entry)
time.append(temp)
writeCsvFile("timeTasks.csv", time)
# Valida se o formato da data está correto
def validateData(date):
try:
temp = date.split("-")
if len(temp[0]) == 2 and len(temp[1]) == 2 and len(temp[2]) == 4:
return True
except IndexError:
return False
return False
# Lista todas as horas alocadas
def listHours(data):
for row in data:
print ("\nData: " + row[0])
print ("Tarefa: " + encodeWin(row[1], "list"))
print ("Horas: " + row[2])
# Busca todas as horas alocadas em determinado dia ou busca todas as tarefas sem horas alocadas
def findTime(time, date, data):
entry = input("Informe o que deseja pesquisar:")
while validateData(entry) == False and entry != "free" and entry != "" and entry != "name" and entry != "date":
entry = input("Opção inválida. Informe o que deseja pesquisar:")
temp = []
if entry == "free":
for row in data:
aux = []
if contaisHours(row[1], time) == False:
aux.append(row[0])
aux.append(row[1])
aux.append("0")
temp.append(aux)
for row in time:
if row[2] == "0":
temp.append(row)
listHours(temp)
if len(temp) > 0:
print (encodeWin("\nTarefas que nao possuem horas alocadas.", "list"))
else:
print (encodeWin("\nNão foram encontradas horas alocadas.", "list"))
elif entry == "date":
hourDate = {}
for row in time:
temp = datetime.datetime.strptime(row[0], "%d-%m-%Y").date()
if temp not in hourDate.keys():
hourDate[temp] = float(row[2])
else:
hourDate[temp] += float(row[2])
hourDate = sorted(hourDate.items())
for d,v in hourDate:
if v > 0:
print (str(d.strftime("%d-%m-%Y")) + ": " + str(v))
elif entry == "name":
entry = input("Informe o nome da tarefa:")
s = 0.0
for row in time:
if entry.lower() == row[1].lower():
temp.append(row)
s+=float(row[2])
listHours(temp)
if s > 0.0:
print ("\nForam encontradas " + str(s) + " horas alocadas.")
else:
print (encodeWin("\nNão foram encontradas horas alocadas.", "list"))
else:
if entry == "":
entry = date.strftime("%d-%m-%Y")
s = 0.0
for row in time:
if entry == row[0] and row[2] != "0":
temp.append(row)
s += float(row[2])
listHours(temp)
if s > 0.0:
print ("\nForam encontradas " + str(s) + " horas alocadas.")
else:
print (encodeWin("\nNão foram encontradas horas alocadas.", "list"))
# Edita uma alocação de hora (data ou tempo)
def editTime(time):
entry = input("Informe o nome da tarefa que deseja editar:")
entry = encodeWin(entry.lower(), "add")
matchs = []
for i in range(len(time)):
if entry == time[i][1].lower():
matchs.append(i)
if len(matchs) == 1:
entry = input("Infome a nova data:")
if entry != "":
if validateData(entry) == True:
time[matchs[0]][0] = entry
entry = input("Informe a nova quantidade de horas:")
if entry != "":
time[matchs[0]][2] = entry
elif len(matchs) > 1:
print ("Tarefa: " + encodeWin(time[matchs[0]][1], "list"))
index = 0
for element in matchs:
print (str(index) + ": Data: " + time[element][0])
if index <= 9:
print (" Horas: " + time[element][2])
else:
print (" Horas: " + time[element][2])
index += 1
entry = input(encodeWin("Informe qual alocação deseja editar (index):", "list"))
while int(entry) < 0 or int(entry) >= len(matchs):
entry = input(encodeWin("Informe uma alocação válida (index):"), "list")
temp = int(entry)
entry = input("Infome a nova data:")
if entry != "":
if validateData(entry) == True:
time[matchs[temp]][0] = entry
entry = input("Informe a nova quantidade de horas:")
if entry != "":
time[matchs[temp]][2] = entry
writeCsvFile("timeTasks.csv", time)
# Remove uma alocação de hora (pesquisa por data)
def removeTime(time, task):
if task == None:
entry = input("Informe o nome da tarefa que deseja remover:")
else:
entry = task
entry = entry.lower()
entry = encodeWin(entry, "add")
temp = []
tempC = []
c = 0
for row in time:
if entry == row[1].lower():
temp.append(row)
tempC.append(c)
c += 1
if len(temp) > 0:
if task == None:
if len(temp) == 1:
del time[tempC[0]]
print (encodeWin("\nAlocação deletada com sucesso.", "list"))
else:
print ("Tarefa: " + encodeWin(temp[0][1], "list"))
index = 0
for element in temp:
print (str(index) + ": Data: " + element[0])
if index <= 9:
print (" Horas: " + element[2])
else:
print (" Horas: " + element[2])
index += 1
entry = input("\nInforme qual das horas alocadas deseja remover:")
while int(entry) < 0 or int(entry) >= len(temp):
entry = input(encodeWin("Informe um índice válido:", "list"))
del time[tempC[int(entry)]]
print (encodeWin("\nAlocação deletada com sucesso.", "list"))
writeCsvFile("timeTasks.csv", time)
else:
for element in tempC:
del time[element]
writeCsvFile("timeTasks.csv", time)
if len(tempC) > 1:
print (encodeWin("\n"+str(len(tempC))+" alocações excluídas.", "list"))
else:
print (encodeWin("\n"+str(len(tempC))+" alocação excluída.", "list"))
else:
print (encodeWin("Nenhuma alocação encontrada.", "list"))
# Verifica se existe alocação de horas para determinada tarefa
def contaisHours(element, time):
for row in time:
if element.lower() == row[1].lower():
return True
return False
# Verifica se existe uma tarefa com o mesmo nome
def verifyTasks(name, data):
for row in data:
if name.lower() == row[1].lower():
return True
return False
# Codifica a string para poder armazenar no arquivo em utf-8 e mostrar no terminal em cp850
def encodeWin(string, op):
if op == "add":
return string
#return byte.decode("cp850").encode("utf8")
elif op == "list":
return string
# Inclui no texto o conteúdo do arquivo
def includeScript(fileName):
data = openTxtFile("Scripts/"+fileName)
string = ""
for row in data:
string += row
return string
# Verifica se a string é uma data (DD-MM-YYYY HH:MM)
def isDate(date):
temp = date.split("-")
if len(temp) == 3:
temp = temp[2].split(" ")
if len(temp) == 2:
temp = temp[1].split(":")
if len(temp) == 2:
return True
return False
# Permite que a tarefa não precise do INC0000
def newEntry(entry):
try:
if entry[0] == "I" and entry[1] == "N" and entry[2] == "C" and entry[3] == "0" and entry[4] == "0" and entry[5] == "0":
if len(entry) == 15:
return entry
else:
return "false"
else:
if len(entry) == 8:
try:
int(entry)
return "INC0000" + entry
except ValueError:
return entry
except IndexError:
return entry
return entry
# Retorna o cpf com a máscara de pontuação 000.000.000-00
def maskCPF(cpf):
cpf = cpf.replace(".", "")
cpf = cpf.replace("-", "")
return cpf[0:3] + "." + cpf[3:6] + "." + cpf[6:9] + "-" + cpf[9:]
# Função que adiciona uma alocação de tempo 0 para a data atual
def addTimeEdit(date, task, time):
aux = []
aux.append(date.strftime("%d-%m-%Y"))
aux.append(task)
aux.append(0)
time.append(aux)
writeCsvFile("timeTasks.csv", time)
# Imprime as ações disponíveis no programa
def help():
print (encodeWin("Você pode realizar as seguintes ações:", "list"))
print ("\nTarefas:")
print ("\t- add: para adicionar uma tarefa;")
print (encodeWin("\t- add free: para adicionar uma tarefa livre de máscaras (título e mensagem);", "list"))
print ("\t- find: para procurar uma tarefa por nome ou data;")
print ("\t- remove: para remover uma tarefa por nome ou indice;")
print ("\t- edit: para editar uma tarefa (reposta + helpdesk);")
print ("\t- edit answer: para editar a resposta helpdesk (usualmente usada para editar respostas vazias);")
print ("\t- list: para listar todas as tarefas cadastradas.")
print ("Time:")
print ("\t- time add: para alocar horas em uma tarefa;")
print ("\t- time find: para procurar horas de determinada tarefa, tarefas sem horas (free) ou tarefas pode date (date);")
print ("\t- time remove: para remover as horas de uma tarefa;")
print ("\t- time edit: para editar a data ou as horas de uma tarefa;")
print ("\t- time list: para listar todas as horas alocadas.")
print (encodeWin("\n- show log: mostra todas as ações realizadas;", "list"))
print ("- --developer: dicas para o desenvolvedor do sistema;")
print (encodeWin("- função toDo no código é referente ao que precisa ser feito no sistema;", "list"))
print ("- exit: sai do programa.")
# Dicas para o desenvolvendor do sistema
def developer():
print (encodeWin("- Se utilizar o bash, digitar 3 como parâmetro (sys); --desativado", "list"))
print (encodeWin("- Configuração atual do cmd chcp 850 (encodeWin);", "list"))
print (encodeWin("- Comando time find > free: quando é listado uma tarefa sem horário, tem que editar aquela alocação (0);", "list"))
print ("- Decode + Encode para salvar em utf8 e printar no terminal em cp850;")
print (encodeWin("- Codificação para scripts em txt UTF8: utf-8-sig;", "list"))
print (encodeWin("- Funiconalidades dos sistema que precisam pesquisar nome de tarefa estão utilizando o parâmetro IN (contém);", "list"))
print (encodeWin("- Mais de 99 alocacoes para a mesma tarefa (quase impossível) verificar espaçamento no edit time;", "list"))
print (encodeWin("- Comando remove: limpa todas as alocações com da tarefa (timeTask);", "list"))
print (encodeWin("- Comando edit: adiciona uma alocação de hora para o dia atual de valor 0; ", "list"))
print (encodeWin("- Executar o arquivo Backup.bat todo dia, antes do expediente terminar para realizar o backup dos arquivos das tarefas e alocações de tempo.", "list"))
# O que precisa ser feito no sistema
def toDo():
print ("Espacamentos no list depois dos :;")
print ("Tratamento de exception quando nao e um numero digitado no CPF")
#print "100%."
# Função main: trata as ações digitadas
def main(entry):
data = readCsvFile("tasks.csv")
time = readCsvFile("timeTasks.csv")
date = datetime.datetime.now()
if entry == "add":
data = add(data, date)
elif entry == "list":
data = list(data)
elif entry == "remove":
data = remove(data, time)
#elif entry == "clean":
# writeCsvFile("tasks.csv", "")
elif entry == "show log":
showLog("logTasks.txt")
elif entry == "find":
find(data)
elif entry == "edit":
edit(data, date, time)
elif entry == "time add":
timeAdd(time, data)
elif entry == "time list":
try:
listHours(time)
except IndexError:
print (encodeWin("Não existe horas trabalhadas.", "list"))
elif entry == "time find":
findTime(time, date, data)
elif entry == "add free":
addFree(data, date)
elif entry == "time edit":
editTime(time)
elif entry == "time remove":
removeTime(time, None)
elif entry == "help":
help()
elif entry == "--developer":
developer()
elif entry == "edit answer":
editAnswer(data)
# Salva no log qual ação foi digitada (mesmo que não seja válida)
temp = date.strftime("%d-%m-%Y %H:%M")
writeTxtFile("logTasks.txt", temp + " - " + entry + "\n")
# Início do programa
entry = input(encodeWin("Digite uma ação:", "list"))
while (entry != "exit"):
main(entry)
entry = input(encodeWin("\nDigite uma ação:", "list"))