You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
914 B
44 lines
914 B
from db import *
|
|
|
|
op = input('op [exp/imp]: ')
|
|
mode = input('mode [0/1]: ')
|
|
|
|
if mode != '0' and mode != '1':
|
|
print('Wrong mode, exit...')
|
|
exit()
|
|
|
|
db = read()
|
|
if op == 'exp':
|
|
out_text = ''
|
|
for i in db[mode]:
|
|
out_text += i + '\n'
|
|
with open('out.txt', 'w') as f:
|
|
f.write(out_text)
|
|
f.close()
|
|
print('Exported!')
|
|
elif op == 'imp':
|
|
print('Select mode: append/replace')
|
|
op_mode = input('app/rep (app): ')
|
|
|
|
with open('out.txt', 'r') as f:
|
|
lines = f.read().split('\n')
|
|
f.close()
|
|
words = []
|
|
for i in lines:
|
|
words.append(i)
|
|
words.remove('')
|
|
|
|
if op_mode == 'app' or op_mode == '':
|
|
# Add existing words
|
|
words += db[mode]
|
|
print('Appending...')
|
|
elif op_mode == 'rep':
|
|
print('Replacing...')
|
|
|
|
# Remove duplicates
|
|
words = list(set(words))
|
|
|
|
db[mode] = words
|
|
write(db)
|
|
|