Skip to content

Commit

Permalink
Auto completion have been added
Browse files Browse the repository at this point in the history
  • Loading branch information
ssavalot committed Apr 20, 2018
1 parent 571d033 commit 40e4e66
Show file tree
Hide file tree
Showing 6 changed files with 364 additions and 55 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ levente.shadow@gmail.com

CHANGELOG

v1.1.0
v1.2
- Auto completion feature have benn added.
This change affects the 'e-mail' and 'send a copy' fields.
The addresses are automatically added to the completion list and
stored in the .nuke/address_cache.csv file.

You can edit manually the address_cache.csv, if you want to change something.
Follow this format:
example1@any.com,example2@any.com,example3@any.com...

v1.1
- Send a copy field have been added. You can send a copy of the message to multiple recipients.
- Code cleanup and better error handling.

Expand Down
1 change: 1 addition & 0 deletions address_cache.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

79 changes: 79 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import sys
import csv
import os


copy_to_lineEdit = ''
copy_to_lineEdit2 = 'asdasdasd, ,asdf, ,a,f as ,'

def create_address_cache():
dir = os.path.dirname(__file__)
csv_filename = os.path.join(dir, 'address_cache.csv')

if not os.path.exists(csv_filename):
with open(csv_filename, 'w'): pass

create_address_cache()

def returnNotMatches(a, b):
a = set(a)
b = set(b)
return [list(b - a), list(a - b)]

def foo(L1, L2):
t = list(set(L1) & set(L2))
return t

def read_csv():
dir = os.path.dirname(__file__)
csv_filename = os.path.join(dir, 'address_cache.csv')
ifile = open(csv_filename, "rb")
reader = csv.reader(ifile)
for row in reader:
pass
return row

def write_csv():
copy_to = [''.join(copy_to_lineEdit2.split())]
copy_to = copy_to[0].split(',')
copy_to = filter(None, copy_to)
# print(copy_to)
dir = os.path.dirname(__file__)
csv_filename = os.path.join(dir, 'address_cache.csv')

if os.stat(csv_filename).st_size == 0:
L3 = copy_to
ifile = open(csv_filename, "wb")

spamwriter = csv.writer(ifile, sys.stdout, delimiter=",", quoting=csv.QUOTE_MINIMAL)
spamwriter.writerow(L3)
ifile.close()
elif copy_to == '':
ifile = open(csv_filename, "rb")
ifile.close()
elif copy_to != read_csv():

L2 = copy_to
a = read_csv()
t = returnNotMatches(a, L2)
g = [j for i in t for j in i]
print(g)
c = foo(read_csv(), L2)
ifile = open(csv_filename, "wb")

spamwriter = csv.writer(ifile, sys.stdout, delimiter=",", quoting=csv.QUOTE_NONE)
spamwriter.writerow(c + g)
ifile.close()
else:
ifile = open(csv_filename, "rb")
ifile.close()

# print('read: ' + str(read_csv()))

# print('write: ' + str(write_csv()))

write_csv()

# print('intersection')
# print(foo(read_csv(), write_csv()))
# print(returnNotMatches(read_csv(), write_csv()))
Loading

0 comments on commit 40e4e66

Please sign in to comment.