[pve-devel] [PATCH v1 pve-esxi-import-tools 4/5] listvms: add arg parser, context manager for connections, fetch helper

Max Carrara m.carrara at proxmox.com
Wed Mar 20 11:08:17 CET 2024


On Wed Mar 20, 2024 at 10:39 AM CET, Lukas Wagner wrote:
>
>
> On  2024-03-19 16:32, Max Carrara wrote:
>
> > +    def _squeeze_and_wrap(text: str) -> str:
> > +        """Makes it easier to write help text using multiline strings."""
> > +
> > +        text = text.replace("\n", " ").strip()
> > +
> > +        # squeeze recurring spaces
> > +        while "  " in text:
> > +            text = text.replace("  ", " ")
> > +
>
> How about `" ".join(text.split())`? :)

That would indeed also work here - I tend to automatically resort to the
while-loop because `str.split()` also splits on `\n`, `\t` and some
other whitespace characters, which is what I *usually* want to avoid,
but in this case it's unnecessary.

Will use your suggestion instead in v2, thanks!





More information about the pve-devel mailing list