def get_stylesheet(template_str): """Format a stylesheet based on a template. Args: template_str: The stylesheet template as string. Return: The formatted template as string. """ colordict = ColorDict(config.section('colors')) fontdict = FontDict(config.section('fonts')) template = jinja2.Template(template_str) return template.render(color=colordict, font=fontdict)
def get_stylesheet(template_str): """Format a stylesheet based on a template. Args: template_str: The stylesheet template as string. Return: The formatted template as string. """ colordict = ColorDict(config.section('colors')) template = jinja2.Template(template_str) return template.render(color=colordict, font=config.section('fonts'), config=objreg.get('config'))
def _get_cmd_completions(include_hidden, include_aliases, prefix=''): """Get a list of completions info for commands, sorted by name. Args: include_hidden: True to include commands annotated with hide=True. include_aliases: True to include command aliases. prefix: String to append to the command name. Return: A list of tuples of form (name, description, bindings). """ assert cmdutils.cmd_dict cmdlist = [] cmd_to_keys = objreg.get('key-config').get_reverse_bindings_for('normal') for obj in set(cmdutils.cmd_dict.values()): hide_debug = obj.debug and not objreg.get('args').debug hide_hidden = obj.hide and not include_hidden if not (hide_debug or hide_hidden or obj.deprecated): bindings = ', '.join(cmd_to_keys.get(obj.name, [])) cmdlist.append((prefix + obj.name, obj.desc, bindings)) if include_aliases: for name, cmd in config.section('aliases').items(): bindings = ', '.join(cmd_to_keys.get(name, [])) cmdlist.append((name, "Alias for '{}'".format(cmd), bindings)) return cmdlist
def _validate_command(self, line, modes=None): """Check if a given command is valid. Args: line: The commandline to validate. modes: A list of modes to validate the commands for, or None. """ from qutebrowser.config import config if line == self.UNBOUND_COMMAND: return commands = line.split(';;') try: first_cmd = commands[0].split(maxsplit=1)[0].strip() cmd = cmdutils.cmd_dict[first_cmd] if cmd.no_cmd_split: commands = [line] except (KeyError, IndexError): pass for cmd in commands: if not cmd.strip(): raise KeyConfigError("Got empty command (line: {!r})!".format( line)) commands = [c.split(maxsplit=1)[0].strip() for c in commands] for cmd in commands: aliases = config.section('aliases') if cmd in cmdutils.cmd_dict: cmdname = cmd elif cmd in aliases: cmdname = aliases[cmd].split(maxsplit=1)[0].strip() else: raise KeyConfigError("Invalid command '{}'!".format(cmd)) cmd_obj = cmdutils.cmd_dict[cmdname] for m in modes or []: cmd_obj.validate_mode(m)
def __init__(self, parent=None): super().__init__(parent) assert cmdutils.cmd_dict cmdlist = [] for obj in set(cmdutils.cmd_dict.values()): if (obj.hide or (obj.debug and not objreg.get('args').debug) or obj.deprecated): pass else: cmdlist.append((obj.name, obj.desc)) for name, cmd in config.section('aliases').items(): cmdlist.append((name, "Alias for '{}'".format(cmd))) cat = self.new_category("Commands") # map each command to its bound keys and show these in the misc column keyconf = objreg.get('key-config') cmd_to_keys = defaultdict(list) for key, cmd in keyconf.get_bindings_for('normal').items(): # put special bindings last if utils.is_special_key(key): cmd_to_keys[cmd].append(key) else: cmd_to_keys[cmd].insert(0, key) for (name, desc) in sorted(cmdlist): self.new_item(cat, name, desc, ', '.join(cmd_to_keys[name]))
def __init__(self, parent=None): super().__init__(parent) assert cmdutils.cmd_dict cmdlist = [] for obj in set(cmdutils.cmd_dict.values()): if obj.hide or (obj.debug and not objreg.get('args').debug): pass else: cmdlist.append((obj.name, obj.desc)) for name, cmd in config.section('aliases').items(): cmdlist.append((name, "Alias for '{}'".format(cmd))) cat = self.new_category("Commands") for (name, desc) in sorted(cmdlist): self.new_item(cat, name, desc)
def _validate_command(self, line): """Check if a given command is valid.""" from qutebrowser.config import config if line == self.UNBOUND_COMMAND: return commands = line.split(';;') try: first_cmd = commands[0].split(maxsplit=1)[0].strip() cmd = cmdutils.cmd_dict[first_cmd] if cmd.no_cmd_split: commands = [line] except (KeyError, IndexError): pass for cmd in commands: if not cmd.strip(): raise KeyConfigError("Got empty command (line: {!r})!".format( line)) commands = [c.split(maxsplit=1)[0].strip() for c in commands] for cmd in commands: aliases = config.section('aliases') if cmd not in cmdutils.cmd_dict and cmd not in aliases: raise KeyConfigError("Invalid command '{}'!".format(cmd))
def _validate_command(self, line): """Check if a given command is valid.""" from qutebrowser.config import config if line == self.UNBOUND_COMMAND: return commands = line.split(';;') try: first_cmd = commands[0].split(maxsplit=1)[0].strip() cmd = cmdutils.cmd_dict[first_cmd] if cmd.no_cmd_split: commands = [line] except (KeyError, IndexError): pass for cmd in commands: if not cmd.strip(): raise KeyConfigError( "Got empty command (line: {!r})!".format(line)) commands = [c.split(maxsplit=1)[0].strip() for c in commands] for cmd in commands: aliases = config.section('aliases') if cmd not in cmdutils.cmd_dict and cmd not in aliases: raise KeyConfigError("Invalid command '{}'!".format(cmd))