From: Daan De Meyer Date: Mon, 8 Aug 2022 13:41:14 +0000 (+0200) Subject: Support ListAction with type=Path X-Git-Tag: v14~87 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=984fc1c0cb590c5db62cd468fc7d2c60907cfd47;p=thirdparty%2Fmkosi.git Support ListAction with type=Path We don't yet properly process multiple values of type Path such as in --extra-tree. This commit updates ListAction to support such cases. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index d5e5bf145..3f7909520 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -4725,14 +4725,17 @@ class ListAction(argparse.Action): if ary is None: ary = [] - if isinstance(values, str): + if isinstance(values, (str, Path)): + # Save the actual type so we can restore it later after processing the argument + t = type(values) + values = str(values) # Support list syntax for comma separated lists as well if self.delimiter == "," and values.startswith("[") and values.endswith("]"): values = values[1:-1] # Make sure delimiters between quotes are ignored. # Inspired by https://stackoverflow.com/a/2787979. - values = [x.strip() for x in re.split(f"""{self.delimiter}(?=(?:[^'"]|'[^']*'|"[^"]*")*$)""", values) if x] + values = [t(x.strip()) for x in re.split(f"""{self.delimiter}(?=(?:[^'"]|'[^']*'|"[^"]*")*$)""", values) if x] if isinstance(values, list): for x in values: