from poezio.plugin import BasePlugin from poezio.decorators import command_args_parser from subprocess import check_output class Plugin(BasePlugin): def init(self): self.api.add_command('indent_xml', self.indent_xml, help='') @command_args_parser.raw def indent_xml(self, xml): indented = check_output(['xmllint', '--format', '-'], input=xml.encode()).decode() indented = indented[indented.index('\n')+1:] self.core.try_execute('code xml ' + indented)