[elbe-devel] [PATCH 1/3] soapclient, templates, virtapt, xmldefaults: fix style errors
Olivier Dion
dion at linutronix.de
Thu Sep 26 22:17:49 CEST 2019
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.
> + def key_strip(self, k):
> + key = textwrap.dedent(k)
> + key = key.strip('\n')
> + return key
> +
Dedent will not remove multiple indentations.
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)
----------------------------------------------------------------------
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
More information about the elbe-devel
mailing list