Beispiel #1
0
 def 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 plugin_name not in self.core.plugin_manager.plugins:
                 return Completion(the_input.new_completion, [], n, quotify=True)
             plugin = self.core.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 plugin_name not in self.core.plugin_manager.plugins:
                 return Completion(the_input.new_completion, [''], n, quotify=True)
             plugin = self.core.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 plugin_name not in self.core.plugin_manager.plugins:
                 return Completion(the_input.new_completion, [''], n, quotify=True)
             plugin = self.core.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 False
     return Completion(the_input.new_completion, end_list, n, quotify=True)
 def 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 plugin_name not in self.core.plugin_manager.plugins:
                 return the_input.new_completion([], n, quotify=True)
             plugin = self.core.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 plugin_name not in self.core.plugin_manager.plugins:
                 return the_input.new_completion([''], n, quotify=True)
             plugin = self.core.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 plugin_name not in self.core.plugin_manager.plugins:
                 return the_input.new_completion([''], n, quotify=True)
             plugin = self.core.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 False
     return the_input.new_completion(end_list, n, quotify=True)
Beispiel #3
0
 def toggle(self, the_input):
     "Completion for /toggle"
     return Completion(
         the_input.new_completion,
         config.options('Poezio'),
         1,
         quotify=False)
Beispiel #4
0
def parse_config(config):
    result = {}
    for option in config.options('reorder'):
        if not option.isdecimal():
            continue
        pos = int(option)
        if pos in result or pos <= 0:
            return

        typ, name = config.get(option, default=':').split(':', maxsplit=1)
        if typ not in TEXT_TO_TAB:
            return
        result[pos] = (TEXT_TO_TAB[typ], name)

    return result
Beispiel #5
0
 def toggle(self, the_input):
     "Completion for /toggle"
     return Completion(the_input.new_completion, config.options('Poezio'), 1, quotify=False)