-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcon.py
More file actions
106 lines (93 loc) · 2.33 KB
/
con.py
File metadata and controls
106 lines (93 loc) · 2.33 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
import csv
import click
from datetime import date
from datetime import timedelta
from datetime import datetime
from time import gmtime, strftime
import time
import re
@click.group()
def cli():
pass
@click.group()
def think():
pass
@think.command()
@click.option('-m')
def add(m):
"""you can add every thiink with -m to help remind and think latter """
contacts_info=[]
if '@' in m:
findc=re.search('(?<=@)\w+',m)
name=findc.group(0)
resualt=findcontact(name)
if resualt != []:
adding(m,resualt)
else:
adding(m,'no')
else:
contacts_info.append('no')
adding(m,contacts_info)
def adding(think,contact):
"""just adding function"""
alan=date.today()
saat=time.strftime("%H:%M:%S")
tarikhalan=date.today()
contacts_info=contact
file=open('think.csv','a+')
print(think,tarikhalan,saat,contacts_info,'--todo',file=file)
file.close()
def findcontact(name):
file=open('contact.csv','r')
readingline=file.readlines()
resualt=[]
for i in readingline:
if name in i:
resualt.append(i)
file.close()
return resualt
def findingthink(string):
file=open('contact.csv','r')
readingline=file.readlines()
resualt=[]
for i in readingline:
if name in i:
resualt.append(i)
file.close()
return resualt
@think.command()
def lthink():
""" list all think """
file=open('think.csv','r')
a=file.readlines()
b=[]
for i in a:
click.echo(click.style(i,fg='blue',bold=True))
b.append(1)
file.close()
def linecounter():
"""countink line"""
file=open('think.csv','r')
a=file.readlines()
b=[]
for i in a:
b.append(1)
file.close()
return sum(b)
@think.command()
def find():
""" find a think """
search=input('what')
file=open('think.csv','r')
a=file.readlines()
b=[]
for i in a:
if search in i:
click.echo(click.style(i,fg='blue',bold=True))
b.append(1)
file.close()
print('Total search count is %s'%sum(b))
a=int(linecounter())
percent=int(sum(b))/a*100
click.echo(click.style('the Percent of this search in total is %s '%percent,fg='red',bold=True))
cli = click.CommandCollection(sources=[cli,think])