Refactoring fixes
This commit is contained in:
parent
2c6df7c527
commit
a4c13bfc53
|
@ -42,10 +42,10 @@ class Controller(ProcessorMixin, Menu, Controller_Data):
|
||||||
programs_list = self.get_sub_group("Search...", "")
|
programs_list = self.get_sub_group("Search...", "")
|
||||||
fixed_programs_list = []
|
fixed_programs_list = []
|
||||||
|
|
||||||
for prog in programs_list:
|
for program in programs_list:
|
||||||
fixed_programs_list.append({'name': prog})
|
fixed_programs_list.append({'name': program})
|
||||||
|
|
||||||
self.favorites = self.call_method("set_favorites_menu", [fixed_programs_list])["setFaves"]
|
self.favorites = self.call_method("set_favorites_menu", [fixed_programs_list])["set_faves"]
|
||||||
self.save_faves(self.favorites)
|
self.save_faves(self.favorites)
|
||||||
continue
|
continue
|
||||||
if "[ Exit ]" in group:
|
if "[ Exit ]" in group:
|
||||||
|
@ -60,7 +60,7 @@ class Controller(ProcessorMixin, Menu, Controller_Data):
|
||||||
self.logger.info(f"[Executing Program] Group: {group} Entry: {entry}")
|
self.logger.info(f"[Executing Program] Group: {group} Entry: {entry}")
|
||||||
self.execute_program(group, entry)
|
self.execute_program(group, entry)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.error(e)
|
self.logger.error(e.printStackTrace())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -150,22 +150,22 @@ class Controller(ProcessorMixin, Menu, Controller_Data):
|
||||||
if "Search..." in group:
|
if "Search..." in group:
|
||||||
group_keys = self.menu_data.keys()
|
group_keys = self.menu_data.keys()
|
||||||
for group_key in group_keys:
|
for group_key in group_keys:
|
||||||
for opt in self.menu_data[group_key]:
|
for option in self.menu_data[group_key]:
|
||||||
keys = opt.keys()
|
keys = option.keys()
|
||||||
if "comment" in keys and len(opt["comment"]) > 0 :
|
if "comment" in keys and len(option["comment"]) > 0 :
|
||||||
if query.lower() in opt["comment"].lower():
|
if query.lower() in option["comment"].lower():
|
||||||
desktop_objects.append( opt["title"] + " || " + opt["comment"] )
|
desktop_objects.append( option["title"] + " || " + option["comment"] )
|
||||||
if query.lower() in opt["title"].lower() or query.lower() in opt["fileName"].lower():
|
if query.lower() in option["title"].lower() or query.lower() in option["fileName"].lower():
|
||||||
desktop_objects.append( opt["title"] + " || " + opt["fileName"].replace(".desktop", "") )
|
desktop_objects.append( option["title"] + " || " + option["fileName"].replace(".desktop", "") )
|
||||||
elif "Favorites" in group:
|
elif "Favorites" in group:
|
||||||
desktop_objects = self.favorites
|
desktop_objects = self.favorites
|
||||||
else:
|
else:
|
||||||
for opt in self.menu_data[group]:
|
for option in self.menu_data[group]:
|
||||||
keys = opt.keys()
|
keys = option.keys()
|
||||||
if "comment" in keys and len(opt["comment"]) > 0 :
|
if "comment" in keys and len(option["comment"]) > 0 :
|
||||||
desktop_objects.append( opt["title"] + " || " + opt["comment"] )
|
desktop_objects.append( option["title"] + " || " + option["comment"] )
|
||||||
else:
|
else:
|
||||||
desktop_objects.append( opt["title"] + " || " + opt["fileName"].replace(".desktop", "") )
|
desktop_objects.append( option["title"] + " || " + option["fileName"].replace(".desktop", "") )
|
||||||
|
|
||||||
return desktop_objects
|
return desktop_objects
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ class ProcessorMixin:
|
||||||
program = parts[0].strip()
|
program = parts[0].strip()
|
||||||
comment = parts[1].strip()
|
comment = parts[1].strip()
|
||||||
|
|
||||||
if "Search..." in group or "Favorites" in group:
|
if group in ["Search...", "Favorites"]:
|
||||||
group_keys = self.menu_data.keys()
|
group_keys = self.menu_data.keys()
|
||||||
for group_key in group_keys:
|
for group_key in group_keys:
|
||||||
self.pre_execute(self.menu_data[group_key], program, comment)
|
self.pre_execute(self.menu_data[group_key], program, comment)
|
||||||
|
@ -22,16 +22,16 @@ class ProcessorMixin:
|
||||||
|
|
||||||
|
|
||||||
def pre_execute(self, options, program, comment):
|
def pre_execute(self, options, program, comment):
|
||||||
for opt in options:
|
for option in options:
|
||||||
if program in opt["title"]:
|
if program in option["title"]:
|
||||||
keys = opt.keys()
|
keys = option.keys()
|
||||||
if comment in opt["comment"] or comment in opt["fileName"]:
|
if comment in [option["comment"], option["fileName"]]:
|
||||||
try:
|
try:
|
||||||
self.execute(opt["tryExec"])
|
self.execute(opt["tryExec"])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
try:
|
try:
|
||||||
if "exec" in keys and len(opt["exec"]):
|
if "exec" in keys and len(option["exec"]):
|
||||||
self.execute(opt["exec"])
|
self.execute(option["exec"])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.debug(e)
|
self.logger.debug(e)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue