-
Notifications
You must be signed in to change notification settings - Fork 0
/
read-codebook.py
executable file
·590 lines (448 loc) · 22.9 KB
/
read-codebook.py
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
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# line wraps @ 120 chars
# read-codebook.py
# Traverse the codebook dB structure and locate individual entries
# Copyright (C) 2016 Teracow Software
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
# later version.
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not,
# see http://www.gnu.org/licenses/.
# If you find this code useful, please let me know. :) teracow@gmail.com
import os
import sys
import getopt
import sqlite3 as lite
import colour_scheme as scheme
SCRIPT_FILE = os.path.basename(sys.argv[0])
SCRIPT_DATE = '2016-08-28'
#BOX_POSITION = 'left' # left of screen
BOX_POSITION = 'center' # center of screen
#BOX_POSITION = 'right' # right of screen
BOX_INDENT = 1 # space from side of screen to box
BOX_TITLE_INDENT = 4 # chars from left border to start of title bookend
# this is ignored if BOX_POSITION is 'center'
TITLE_SPACING = 1 # space between bookends and title on left and right
MENU_ITEM_INDENT = 1 # space between the left border and the index parentheses
MENU_ITEM_GAP = 1 # space between index parentheses and the displayed item
MENU_ITEM_TAIL = 1 # space between item and right border
MENU_ITEM_FAVORITE = ' ✶' # show this when menu item is a favorite
PROMPT_INDENT = 1 # from left of box to start of prompt
ENTRY_NAME_INDENT = 1 # from left of box to name
ENTRY_VALUE_INDENT = 4 # from left of box to value
ENTRY_NAME_FAVORITE = ' ✶' # show this when displaying favorite item fields
# these are only used for calculation
BOX_TITLE_CHARS_LENGTH = 4 # left corner, title bookends, right corner
BOX_VERTICAL_CHARS_LENGTH = 2 # upright lines
BOX_FOOTER_CHARS_LENGTH = 2 # left corner, right corner
MENU_ROW_MIN_LENGTH = MENU_ITEM_INDENT + 2 + MENU_ITEM_GAP + (len(MENU_ITEM_FAVORITE)) + MENU_ITEM_TAIL\
+ BOX_VERTICAL_CHARS_LENGTH
SCRIPT_DETAILS = '{} ({})'.format(scheme.COLOUR_LIGHT_FG + scheme.COLOUR_BOLD + SCRIPT_FILE + scheme.COLOUR_RESET,
SCRIPT_DATE)
def draw_menu(title, table, column, options, prompt_only = False, special = False):
# if prompt_only is True : don't show menu box and items, only show prompt line
# if special is True : menu title colour will be scheme.COLOURS_MENU_TITLE_SPECIAL
# if special is False : menu title colour will be scheme.COLOURS_MENU_TITLE_REGULAR
total_items = len(table)
if prompt_only: display_menu = False
else:
display_menu = True
recalc_box_size_and_position(title, table, column)
header, separator, footer = generate_menu_lines(title, special)
while True:
if display_menu:
print(header)
for index, row in enumerate(table):
try:
show_favorite = row['favorite']
except:
show_favorite = ''
print(generate_menu_line_item(index + 1, row[column], show_favorite))
if total_items > 0: print(separator)
if 'S' in options: print(generate_menu_line_option('S', 'Search'))
if 'W' in options: print(generate_menu_line_option('W', 'Write to text file'))
if 'F' in options: print(generate_menu_line_option('F', 'Favorites'))
if 'M' in options: print(generate_menu_line_option('M', 'Main menu'))
if 'B' in options: print(generate_menu_line_option('B', 'Back'))
print(generate_menu_line_option('Q', 'Quit'))
print(footer)
print()
try:
user_selection = input(generate_menu_prompt())
print()
except KeyboardInterrupt:
print('\n')
sys.exit()
# allowed keys based on 'options'
if user_selection.isdigit():
if int(user_selection) > 0 and int(user_selection) <= total_items: break
else:
if user_selection.upper() == 'Q': sys.exit()
if 'B' in options:
if user_selection.upper() == 'B':
user_selection = 0
break
if 'W' in options:
if user_selection.upper() == 'W':
user_selection = -1
break
if 'S' in options:
if user_selection.upper() == 'S':
user_selection = -2
break
if 'F' in options:
if user_selection.upper() == 'F':
user_selection = -3
break
if 'M' in options:
if user_selection.upper() == 'M':
user_selection = -4
break
display_menu = False # for any other char - only re-show prompt
return int(user_selection)
def generate_menu_lines(title, special = False):
title_length = calc_title_length(title)
if special: title_colour = scheme.COLOURS_MENU_TITLE_SPECIAL
else: title_colour = scheme.COLOURS_MENU_TITLE_REGULAR
if title:
menu_header = (' ' * (box_left + ((box_width // 2) - ((len(SCRIPT_FILE) + len(SCRIPT_DATE) + 3) // 2))))\
+ SCRIPT_DETAILS + '\n\n'
if BOX_POSITION == 'left':
left_padding = '─' * BOX_TITLE_INDENT
right_padding = '─' * (box_width - title_length)
elif BOX_POSITION == 'center':
left_padding = '─' * ((box_width - title_length) // 2)
right_padding = '─' * (box_width - title_length - len(left_padding))
else:
left_padding = '─' * (box_width - title_length)
right_padding = '─' * BOX_TITLE_INDENT
header_template = (' ' * box_left) + '{}◤' + left_padding + '┤' + (' ' * TITLE_SPACING) + '{}' + title\
+ (' ' * TITLE_SPACING) + '{}├' + right_padding + '┐{}'
menu_header += header_template.format(scheme.COLOURS_MENU_BOX, title_colour, scheme.COLOUR_RESET
+ scheme.COLOURS_MENU_BOX, scheme.COLOUR_RESET)
separator_template = (' ' * box_left) + '{}├' + ('─' * (box_width - BOX_VERTICAL_CHARS_LENGTH)) + '┤{}'
menu_separator = separator_template.format(scheme.COLOURS_MENU_BOX, scheme.COLOUR_RESET)
else:
header_template = (' ' * box_left) + '{}◤' + ('─' * (box_width - BOX_VERTICAL_CHARS_LENGTH)) + '┐{}'
menu_header = header_template.format(scheme.COLOURS_MENU_BOX, scheme.COLOUR_RESET)
menu_separator = ''
footer_template = (' ' * box_left) + '{}└' + ('─' * (box_width - BOX_VERTICAL_CHARS_LENGTH)) + '◢{}'
menu_footer = footer_template.format(scheme.COLOURS_MENU_BOX, scheme.COLOUR_RESET)
return menu_header, menu_separator, menu_footer
def generate_menu_line_item(index, text, show_favorite = False):
if show_favorite: line_favorite = scheme.COLOURS_FAVORITE_STAR + MENU_ITEM_FAVORITE
else: line_favorite = (' ' * len(MENU_ITEM_FAVORITE))
template = (' ' * box_left) + '{}│' + (' ' * MENU_ITEM_INDENT) + '({}' + str(index) + '{})' + (' ' * MENU_ITEM_GAP)\
+ '{}' + text + (' ' * (box_width - calc_line_item_width(index, text) - MENU_ROW_MIN_LENGTH))\
+ line_favorite + (' ' * MENU_ITEM_TAIL) + scheme.COLOUR_RESET + scheme.COLOURS_MENU_BOX + '{}│{}'
return template.format(scheme.COLOURS_MENU_BOX, scheme.COLOURS_ALLOWED_ITEM_KEY, scheme.COLOUR_RESET
+ scheme.COLOURS_MENU_BOX, scheme.COLOURS_MENU_ITEM, scheme.COLOUR_RESET
+ scheme.COLOURS_MENU_BOX, scheme.COLOUR_RESET)
def generate_menu_line_option(char, text):
template = (' ' * box_left) + '{}│' + (' ' * MENU_ITEM_INDENT) + '({}' + char + '{})' + (' ' * MENU_ITEM_GAP)\
+ text + (' ' * (box_width - calc_line_item_width(char, text) - MENU_ROW_MIN_LENGTH))\
+ (' ' * len(MENU_ITEM_FAVORITE)) + (' ' * MENU_ITEM_TAIL) + '│{}'
return template.format(scheme.COLOURS_MENU_BOX, scheme.COLOURS_ALLOWED_OPTION_KEY, scheme.COLOUR_RESET
+ scheme.COLOURS_MENU_BOX, scheme.COLOUR_RESET)
def generate_menu_prompt():
template = (' ' * (box_left + PROMPT_INDENT)) + '{}select:{} '
return template.format(scheme.COLOURS_PROMPT, scheme.COLOUR_RESET)
def generate_search_prompt():
template = (' ' * (box_left + PROMPT_INDENT)) + '{}enter text to search for:{} '
return template.format(scheme.COLOURS_PROMPT, scheme.COLOUR_RESET)
def longest_column_entry(entries, name):
# checks the length of every item in column 'name' and returns the longest
current_length = 1
for index, entry in enumerate(entries):
field_length = calc_line_item_width(index, entry[name])
if field_length > current_length: current_length = field_length
return current_length
def calc_line_item_width(index, text):
return len(str(index) + text)
def calc_title_length(title):
length = len(title) + BOX_TITLE_CHARS_LENGTH + (TITLE_SPACING * 2)
if BOX_POSITION != 'center': length += BOX_TITLE_INDENT
return length
def recalc_box_size_and_position(title, table, column):
global box_width, box_left
box_width = 31 # minimum box width
line_length = longest_column_entry(table, column)
title_length = calc_title_length(title)
if (line_length + MENU_ROW_MIN_LENGTH) > box_width:
box_width = line_length + MENU_ROW_MIN_LENGTH
if title_length > box_width:
box_width = title_length
if BOX_POSITION == 'left':
box_left = BOX_INDENT
elif BOX_POSITION == 'right':
rows, columns = get_screen_size()
box_left = columns - BOX_INDENT - box_width
else:
rows, columns = get_screen_size()
box_left = (columns // 2) - (box_width // 2)
def get_db_categories():
base_sql = ('SELECT '
'id AS category_id, '
'name AS category_name '
'FROM categories '
'ORDER BY category_name')
return SOURCE_DB.cursor().execute(base_sql).fetchall()
def get_db_entries_from_category(category_id):
base_sql = ('SELECT '
'categories.id AS category_id, '
'categories.name AS category_name, '
'entries.id AS entry_id, '
'entries.name AS entry_name, '
'entries.type AS entry_type, '
'entries.is_favorite AS favorite '
'FROM categories '
'JOIN entries ON entries.category_id = categories.id ')
return SOURCE_DB.cursor().execute(base_sql + 'WHERE category_id = ? ORDER BY entry_name COLLATE NOCASE',
(category_id,)).fetchall()
def get_db_fields_from_entry(entry_id):
base_sql = ('SELECT entry_id, '
'entries.name AS entry_name, '
'entries.type AS entry_type, '
'types.name AS field_name, '
'fields.value, '
'fields.idx AS field_index, '
'types.mode AS data_type '
'FROM entries '
'JOIN fields ON fields.entry_id = entries.id '
'LEFT JOIN types ON types.id = fields.type_id ')
return SOURCE_DB.cursor().execute(base_sql + 'WHERE entry_id = ? ORDER BY field_index', (entry_id,)).fetchall()
def get_db_search(text):
base_sql = ('SELECT entries.id AS entry_id, '
'entries.name AS entry_name, '
'entries.type AS entry_type, '
'entries.is_favorite AS favorite, '
'fields.value '
'FROM entries '
'JOIN fields ON fields.entry_id = entries.id '
'LEFT JOIN types ON types.id = fields.type_id ')
return SOURCE_DB.cursor().execute(base_sql + 'WHERE value LIKE ? OR entry_name LIKE ? COLLATE NOCASE GROUP BY\
entry_name ORDER BY entry_name', ('%' + text + '%', '%' + text + '%')).fetchall()
def get_db_favorites():
base_sql = ('SELECT entries.id AS entry_id, '
'entries.name AS entry_name, '
'entries.type AS entry_type, '
'entries.is_favorite AS favorite '
'FROM entries '
'WHERE favorite = 1 ORDER BY entry_name COLLATE NOCASE')
return SOURCE_DB.cursor().execute(base_sql).fetchall()
def generate_single_entry_screen(title, fields, favorite = False):
rows, columns = get_screen_size()
if favorite:
title_length = calc_title_length(title + ENTRY_NAME_FAVORITE)
title += scheme.COLOURS_FAVORITE_STAR + ENTRY_NAME_FAVORITE
else:
title_length = calc_title_length(title)
if BOX_POSITION == 'left':
left_padding = '═' * BOX_TITLE_INDENT
right_padding = '═' * (columns - (BOX_INDENT * 2) - title_length)
elif BOX_POSITION == 'center':
left_padding = '═' * ((columns - title_length) // 2)
right_padding = ('═' * (columns - (BOX_INDENT * 2) - title_length - len(left_padding)))
else:
left_padding = '═' * (columns - (BOX_INDENT * 2) - title_length)
right_padding = '═' * BOX_TITLE_INDENT
template_header = (' ' * BOX_INDENT) + '{}◤' + left_padding + '╡' + (' ' * TITLE_SPACING) + '{}' + title + '{}'\
+ (' ' * TITLE_SPACING) + '╞' + right_padding + '╗{}\n'
header = template_header.format(scheme.COLOURS_SINGLE_ENTRY_BOX, scheme.COLOURS_SINGLE_ENTRY_TITLE,
scheme.COLOUR_RESET + scheme.COLOURS_SINGLE_ENTRY_BOX, scheme.COLOUR_RESET)
content = ''
for field in fields:
if field['data_type'] == 'note' or field['entry_type'] == 1:
content += generate_note_screen('Note', field['value'], columns)
break
else:
content += generate_field_screen(field['field_name'], field['value'], columns)
template_footer = (' ' * BOX_INDENT) + '{}╚' + ('═' * (columns - BOX_FOOTER_CHARS_LENGTH - (BOX_INDENT * 2)))\
+ '◢{}'
footer = template_footer.format(scheme.COLOURS_SINGLE_ENTRY_BOX, scheme.COLOUR_RESET)
return header + content + footer
def generate_single_entry_file(fields):
content = ''
for field in fields:
if field['data_type'] == 'note' or field['entry_type'] == 1:
content += generate_field_file('Note', field['value'])
else:
content += generate_field_file(field['field_name'], field['value']) + '\n'
return content
def generate_note_screen(name, value, columns):
name += ':'
name_min_length = len(name) + BOX_VERTICAL_CHARS_LENGTH + ENTRY_NAME_INDENT
template_name_line = (' ' * BOX_INDENT) + '{}║' + (' ' * ENTRY_NAME_INDENT) + '{}' + name\
+ (' ' * (columns - BOX_INDENT - name_min_length - BOX_INDENT)) + '{}║{}\n'
name_line = template_name_line.format(scheme.COLOURS_SINGLE_ENTRY_BOX, scheme.COLOURS_SINGLE_ENTRY_NAME,
scheme.COLOURS_SINGLE_ENTRY_BOX, scheme.COLOUR_RESET)
value_line = ''
for line in value.splitlines():
line_min_length = len(line) + BOX_VERTICAL_CHARS_LENGTH + ENTRY_VALUE_INDENT
template_value_line = (' ' * BOX_INDENT) + '{}║' + (' ' * ENTRY_VALUE_INDENT) + '{}' + line\
+ (' ' * (columns - BOX_INDENT - line_min_length - BOX_INDENT)) + '{}║{}\n'
value_line += template_value_line.format(scheme.COLOURS_SINGLE_ENTRY_BOX, scheme.COLOURS_SINGLE_ENTRY_VALUE,
scheme.COLOURS_SINGLE_ENTRY_BOX, scheme.COLOUR_RESET)
return name_line + value_line
def generate_field_screen(name, value, columns):
name += ':'
name_min_length = len(name) + BOX_VERTICAL_CHARS_LENGTH + ENTRY_NAME_INDENT
value_min_length = len(value) + BOX_VERTICAL_CHARS_LENGTH + ENTRY_VALUE_INDENT
template_name_line = (' ' * BOX_INDENT) + '{}║' + (' ' * ENTRY_NAME_INDENT) + '{}' + name\
+ (' ' * (columns - BOX_INDENT - name_min_length - BOX_INDENT)) + '{}║{}\n'
name_line = template_name_line.format(scheme.COLOURS_SINGLE_ENTRY_BOX, scheme.COLOURS_SINGLE_ENTRY_NAME,
scheme.COLOURS_SINGLE_ENTRY_BOX, scheme.COLOUR_RESET)
template_value_line = (' ' * BOX_INDENT) + '{}║' + (' ' * ENTRY_VALUE_INDENT) + '{}' + value\
+ (' ' * (columns - BOX_INDENT - value_min_length - BOX_INDENT)) + '{}║{}\n'
value_line = template_value_line.format(scheme.COLOURS_SINGLE_ENTRY_BOX, scheme.COLOURS_SINGLE_ENTRY_VALUE,
scheme.COLOURS_SINGLE_ENTRY_BOX, scheme.COLOUR_RESET)
return name_line + value_line
def generate_field_file(name, value):
return name + ':\n' + value + '\n'
def write_fields_to_file(filename, fields):
target_pathfile = filename.replace(' ', '_').replace('/', '_').replace('\\', '_').replace('?', '_') + '.txt'
content = generate_single_entry_file(fields)
template = (' ' * (box_left + PROMPT_INDENT)) + '{} {} {}\n'
if not os.path.exists(target_pathfile):
with open(target_pathfile, 'w') as text_file:
text_file.write(content)
marker = "*"
message = scheme.COLOURS_WRITE_OK + 'written to file' + scheme.COLOUR_RESET
else:
marker = "!"
message = scheme.COLOURS_WRITE_FAIL + 'did not write (file already exists)' + scheme.COLOUR_RESET
print(template.format(marker, message, marker))
return
def get_screen_size():
rows_str, columns_str = os.popen('stty size', 'r').read().split()
return int(rows_str), int(columns_str)
def reset_display():
print('\033c')
return
def show_help():
print('\nUsage: ./{} -i [inputfile]'.format(SCRIPT_FILE))
sys.exit()
def what_are_my_options(argv):
input_pathfile = None
try:
opts, args = getopt.getopt(argv,'hvi:',['help','version','input-file='])
except getopt.GetoptError:
show_help()
for opt, arg in opts:
if opt in ('-h', '--help'):
show_help()
elif opt in ('-v', '--version'):
sys.exit()
elif opt in ('-i', '--input-file'):
if not arg:
show_help()
input_pathfile = arg
if not input_pathfile: show_help()
return input_pathfile
def main():
menu_stack = []
current_menu = 'categories'
all_categories = get_db_categories()
while True:
if current_menu == 'categories':
reset_display()
category_menu_index = draw_menu('categories', all_categories, 'category_name', 'FS')
menu_stack.append(current_menu)
if category_menu_index == -2:
current_menu = 'search'
elif category_menu_index == -3:
current_menu = 'favorites'
else:
category_row = all_categories[category_menu_index - 1]
current_menu = 'entries'
if current_menu == 'entries':
reset_display()
category_entries = get_db_entries_from_category(category_row['category_id'])
entry_menu_index = draw_menu(category_row['category_name'], category_entries, 'entry_name', 'BFMS')
if entry_menu_index == 0:
current_menu = menu_stack.pop()
elif entry_menu_index == -2:
menu_stack.append(current_menu)
current_menu = 'search'
elif entry_menu_index == -3:
menu_stack.append(current_menu)
current_menu = 'favorites'
elif entry_menu_index == -4:
menu_stack = []
current_menu = 'categories'
else:
menu_stack.append(current_menu)
entry_row = category_entries[entry_menu_index - 1]
current_menu = 'fields'
if current_menu == 'search':
try:
search_text = input(generate_search_prompt())
except KeyboardInterrupt:
current_menu = menu_stack.pop()
else:
if search_text: current_menu = 'search results'
else: print()
if current_menu == 'search results':
reset_display()
search_entries = get_db_search(search_text)
search_menu_index = draw_menu('Search results for \"' + search_text + '\"', search_entries, 'entry_name',
'BFM', None, True)
if search_menu_index == 0:
current_menu = menu_stack.pop()
elif search_menu_index == -3:
menu_stack.append(current_menu)
current_menu = 'favorites'
elif search_menu_index == -4:
menu_stack = []
current_menu = 'categories'
else:
menu_stack.append(current_menu)
entry_row = search_entries[search_menu_index - 1]
current_menu = 'fields'
if current_menu == 'favorites':
reset_display()
favorites_entries = get_db_favorites()
favorite_menu_index = draw_menu('Favorites', favorites_entries, 'entry_name', 'BMS', None, True)
if favorite_menu_index == 0:
current_menu = menu_stack.pop()
elif favorite_menu_index == -2:
menu_stack.append(current_menu)
current_menu = 'search'
elif favorite_menu_index == -4:
menu_stack = []
current_menu = 'categories'
else:
menu_stack.append(current_menu)
entry_row = favorites_entries[favorite_menu_index - 1]
current_menu = 'fields'
if current_menu == 'fields':
reset_display()
entry_name = entry_row['entry_name']
entry_fields = get_db_fields_from_entry(entry_row['entry_id'])
content = generate_single_entry_screen(entry_name, entry_fields, entry_row['favorite'])
print(content + '\n')
prompt_only = False
while True:
fields_menu_index = draw_menu('', '', '', 'BMW', prompt_only)
if fields_menu_index == 0:
current_menu = menu_stack.pop()
break
elif fields_menu_index == -1:
write_fields_to_file(entry_name, entry_fields)
prompt_only = True
elif fields_menu_index == -4:
menu_stack = []
current_menu = 'categories'
break
if __name__ == '__main__':
print(SCRIPT_DETAILS)
database_file = what_are_my_options(sys.argv[1:])
if not os.path.exists(database_file):
print('\n! Input file not found! [{}]'.format(database_file))
else:
SOURCE_DB = lite.connect(database_file)
SOURCE_DB.row_factory = lite.Row
main()