Browse Source

searcher does not call __init_table__ while updating

removed duplicate exe options
master
Raphael Roberts 7 years ago
parent
commit
def2a4c05d
  1. 16
      ext_open/ext_open.py
  2. 12
      ext_open/opts.json
  3. 1
      ext_open/searcher.py

16
ext_open/ext_open.py

@ -6,10 +6,11 @@ import opener
import pyperclip import pyperclip
import searcher import searcher
parser = argparse.ArgumentParser(prog='ext-open',prefix_chars=prefix_char) parser = argparse.ArgumentParser(prog='ext-open',prefix_chars=prefix_char)
for opt in prefix:
parser.add_argument(*opt.pop('ostring'),**opt)
sub_parsers = parser.add_subparsers(dest='ext') sub_parsers = parser.add_subparsers(dest='ext')
exe_parser = sub_parsers.add_parser('exe',prefix_chars=prefix_char) exe_parser = sub_parsers.add_parser('exe',prefix_chars=prefix_char)
update_parser = sub_parsers.add_parser('update',prefix_chars=prefix_char)
for opt in prefix:
update_parser.add_argument(*opt.pop('ostring'),**opt)
for opt in exe: for opt in exe:
opt = opt.copy() opt = opt.copy()
exe_parser.add_argument(*opt.pop('ostring'),**opt) exe_parser.add_argument(*opt.pop('ostring'),**opt)
@ -18,11 +19,12 @@ for ext in exts:
for opt in ext['opts']+common: for opt in ext['opts']+common:
opt = opt.copy() opt = opt.copy()
sub_parser.add_argument(*opt.pop('ostring'),**opt) sub_parser.add_argument(*opt.pop('ostring'),**opt)
if __name__ == '__main__':
if __name__ == "__main__":
args = parser.parse_args() args = parser.parse_args()
print(args)
ext = args.ext ext = args.ext
s = searcher.Searcher(ext,args.case_sensitive)
if ext == 'update':
ext = args.update_ext
s = searcher.Searcher(ext)
if args.trim_history is not None: if args.trim_history is not None:
if args.trim_history.lower() == 'all': if args.trim_history.lower() == 'all':
if input('Are you sure?\n(y/n): ') == 'y': if input('Are you sure?\n(y/n): ') == 'y':
@ -30,9 +32,9 @@ if __name__ == '__main__':
elif args.trim_history.isdecimal: elif args.trim_history.isdecimal:
n = int(args.trim_history) n = int(args.trim_history)
s.clean(n) s.clean(n)
del args.__dict__['trim_history']
if args.__dict__.pop('update'):
s.update() s.update()
else:
s = searcher.Searcher(args.ext)
if args.__dict__.pop('exact'): if args.__dict__.pop('exact'):
matches = s.exact(args.query) matches = s.exact(args.query)
else: else:

12
ext_open/opts.json

@ -1,4 +1,3 @@
{ {
"bools": [ "bools": [
{ {
@ -89,11 +88,6 @@
} }
], ],
"prefix": [ "prefix": [
{
"action": "store_true",
"help": "Update the listings for ext",
"ostring": ["+u", "++update"]
},
{ {
"help": "Trim backup history, either all or N updates", "help": "Trim backup history, either all or N updates",
"metavar": "(all | N)", "metavar": "(all | N)",
@ -103,6 +97,12 @@
"action": "store_true", "action": "store_true",
"help": "updates the modified times for paths in config\nuseful for ensuring all new files are found", "help": "updates the modified times for paths in config\nuseful for ensuring all new files are found",
"ostring": ["+m", "++update-modified-times"] "ostring": ["+m", "++update-modified-times"]
},
{
"ostring": [],
"metavar": "ext",
"dest": "update_ext",
"help": "file extension listing to update"
} }
], ],
"prefix_char": "+" "prefix_char": "+"

1
ext_open/searcher.py

@ -40,6 +40,7 @@ class Searcher:
self.update_proc = None self.update_proc = None
self.case = case_sensitive self.case = case_sensitive
self.index = '{}_index'.format(ext) self.index = '{}_index'.format(ext)
if not self.updating:
self.__init_table__() self.__init_table__()
def __init_table__(self): def __init_table__(self):

Loading…
Cancel
Save