From 5d6368e562a5173afa535c26058b6e314738d712 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Tue, 6 Sep 2022 17:35:21 -0400 Subject: [PATCH] mconf: Do not wrap choices manually We already use textwrap.wrap() for that and it will correctly split on spaces. --- mesonbuild/mconf.py | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py index 0c07a352a..2ac12dda6 100644 --- a/mesonbuild/mconf.py +++ b/mesonbuild/mconf.py @@ -156,26 +156,10 @@ class Conf: else: value = make_lower_case(value) - if choices: - if isinstance(choices, list): - choices_list = make_lower_case(choices) - current = '[' - while choices_list: - i = choices_list.pop(0) - if len(current) + len(i) >= self.max_choices_line_length: - self._add_line(name, value, current + ',', descr) - name = '' - value = '' - descr = '' - current = ' ' - if len(current) > 1: - current += ', ' - current += i - choices = current + ']' - else: - choices = make_lower_case(choices) + if isinstance(choices, list): + choices = '[{}]'.format(', '.join(make_lower_case(choices))) else: - choices = '' + choices = make_lower_case(choices) self._add_line(name, value, choices, descr)