[elbe-devel] [PATCH 1/3] soapclient, templates, virtapt, xmldefaults: fix style errors
Olivier Dion
dion at linutronix.de
Sat Sep 28 04:12:37 CEST 2019
On 2019-09-27T08:30:39-0400, Torben Hohn <torben.hohn at linutronix.de> wrote:
> > Dedent will not remove multiple indentations.
> where do you see multiple indentations ?
> >>> dedent('\n bla\n bla\n')
> '\nbla\nbla\n'
> this looks like what we want.
> please elaborate, what you see as the problem here.
> >
> > Try this
> > ----------------------------------------------------------------------
> > buf = []
> > for line in url.text('raw-key').splitlines():
> > if len(line) > 1:
> > buf.append(line.strip(" \t"))
> > key = '\n'.join(buf)
> > self.add_key(key)
> > ----------------------------------------------------------------------
> this at least fits into 80 characters :)
> but i have not given up on dedent and its simplicity yet.
> mm... but i guess, you will prove me wrong.
----------------------------------------------------------------------
>>> import textwrap
>>> a = "\n\n\tHello\n\t\tWorld!\n\n"
>>> textwrap.dedent(a)
'\n\nHello\n\tWorld!\n\n'
---------------------------------------------------------------------
as you can see, if indentation are not at the same level, which in
theory chould happen with some bad editor .. VSCode .., this result
in some indentation not being striped. Try the example above and mix
some space and tab, there you have it.
--
Olivier Dion
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
More information about the elbe-devel
mailing list