[elbe-devel] [PATCH 1/3] soapclient, templates, virtapt, xmldefaults: fix style errors

Torben Hohn torben.hohn at linutronix.de
Fri Sep 27 14:30:39 CEST 2019


On Thu, Sep 26, 2019 at 04:17:49PM -0400, Olivier Dion wrote:
> 
> On 2019-09-26T09:22:04-0400, Akash Satamkar <akash at linutronix.de> wrote:
> 
> > @@ -169,9 +165,15 @@ class VirtApt(object):
> >              # I could make a none global 'noauth' flag for mirrors
> >              for url in self.xml.node('project/mirror/url-list'):
> >                  if url.has('raw-key'):
> > -                    key = "\n".join(line.strip(" \t") for line in url.text('raw-key').splitlines()[1:-1])
> > +                    for line in url.text('raw-key'):
> > +                        key = self.key_strip(line)
> >                      self.add_key(key)
> 
> You're rewriting the key for every iteration here? This result in the
> empty string at the end.

yeah. we only want to rewrite it once.

> 
> > +    def key_strip(self, k):
> > +        key = textwrap.dedent(k)
> > +        key = key.strip('\n')
> > +        return key
> > +
> 
> 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.

> 
> Although I'm not sure if PGP public block key require a newline at the
> end.  Might check for that.


> 
> There's also 2 other places where we use this scheme, you might want to
> do the same there.
> 
> --
> Olivier Dion
> Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner



More information about the elbe-devel mailing list