def completion_set(self, the_input): """Completion for /set""" args = common.shell_split(the_input.text) n = the_input.get_argument_position(quoted=True) if n >= len(args): args.append('') if n == 1: if '|' in args[1]: plugin_name, section = args[1].split('|')[:2] if not plugin_name in self.plugin_manager.plugins: return the_input.new_completion([], n, quotify=True) plugin = self.plugin_manager.plugins[plugin_name] end_list = [ '%s|%s' % (plugin_name, section) for section in plugin.config.sections() ] else: end_list = set(config.options('Poezio')) end_list.update(config.default.get('Poezio', {})) end_list = list(end_list) end_list.sort() elif n == 2: if '|' in args[1]: plugin_name, section = args[1].split('|')[:2] if not plugin_name in self.plugin_manager.plugins: return the_input.new_completion([''], n, quotify=True) plugin = self.plugin_manager.plugins[plugin_name] end_list = set(plugin.config.options(section or plugin_name)) if plugin.config.default: end_list.update( plugin.config.default.get(section or plugin_name, {})) end_list = list(end_list) end_list.sort() elif not config.has_option('Poezio', args[1]): if config.has_section(args[1]): end_list = config.options(args[1]) end_list.append('') else: end_list = [] else: end_list = [str(config.get(args[1], '')), ''] elif n == 3: if '|' in args[1]: plugin_name, section = args[1].split('|')[:2] if not plugin_name in self.plugin_manager.plugins: return the_input.new_completion([''], n, quotify=True) plugin = self.plugin_manager.plugins[plugin_name] end_list = [ str(plugin.config.get(args[2], '', section or plugin_name)), '' ] else: if not config.has_section(args[1]): end_list = [''] else: end_list = [str(config.get(args[2], '', args[1])), ''] else: return return the_input.new_completion(end_list, n, quotify=True)
def completion_set(self, the_input): """Completion for /set""" args = common.shell_split(the_input.text) n = the_input.get_argument_position(quoted=True) if n >= len(args): args.append("") if n == 1: if "|" in args[1]: plugin_name, section = args[1].split("|")[:2] if not plugin_name in self.plugin_manager.plugins: return the_input.new_completion([], n, quotify=True) plugin = self.plugin_manager.plugins[plugin_name] end_list = ["%s|%s" % (plugin_name, section) for section in plugin.config.sections()] else: end_list = set(config.options("Poezio")) end_list.update(config.default.get("Poezio", {})) end_list = list(end_list) end_list.sort() elif n == 2: if "|" in args[1]: plugin_name, section = args[1].split("|")[:2] if not plugin_name in self.plugin_manager.plugins: return the_input.new_completion([""], n, quotify=True) plugin = self.plugin_manager.plugins[plugin_name] end_list = set(plugin.config.options(section or plugin_name)) if plugin.config.default: end_list.update(plugin.config.default.get(section or plugin_name, {})) end_list = list(end_list) end_list.sort() elif not config.has_option("Poezio", args[1]): if config.has_section(args[1]): end_list = config.options(args[1]) end_list.append("") else: end_list = [] else: end_list = [str(config.get(args[1], "")), ""] elif n == 3: if "|" in args[1]: plugin_name, section = args[1].split("|")[:2] if not plugin_name in self.plugin_manager.plugins: return the_input.new_completion([""], n, quotify=True) plugin = self.plugin_manager.plugins[plugin_name] end_list = [str(plugin.config.get(args[2], "", section or plugin_name)), ""] else: if not config.has_section(args[1]): end_list = [""] else: end_list = [str(config.get(args[2], "", args[1])), ""] else: return return the_input.new_completion(end_list, n, quotify=True)
def completion_toggle(self, the_input): "Completion for /toggle" return the_input.new_completion(config.options('Poezio'), 1, quotify=False)
from config import config # load config global_filter_addr_to_parameter_index = { int(k): int(v) for k, v in dict(config["midi.global_filter_binds"]).items() } midi_addr_to_filter_bind = { int(v): k for k, v in dict(config["midi.filter_binds"]).items() } controls = {int(k): v for k, v in dict(config["midi.controls"]).items()} modifiers = {k: int(v) for k, v in dict(config["midi.modifiers"]).items()} toggle_buttons_list = list(range(32, 72)) trigger_buttons_list = [ int(value) for value in config.options("midi.trigger_buttons") ] # trigger and toggle lists are exclusive for bt in trigger_buttons_list: print(bt) toggle_buttons_list.remove(bt) class MidiController: def __init__(self, orchestrator): self.o = orchestrator midiin = rtmidi.MidiIn( rtmidi.midiutil.get_api_from_environment(rtmidi.API_UNSPECIFIED)) ports = midiin.get_ports() for i in range(len(ports)): if "nanoKONTROL" in ports[i]: