UserArrayOption: Make listify_value() a static method

pull/10332/head
Xavier Claessens 2 years ago
parent 48c17b7ae6
commit 7600856e0a
  1. 8
      mesonbuild/coredata.py
  2. 2
      mesonbuild/mcompile.py

@ -256,7 +256,8 @@ class UserArrayOption(UserOption[T.List[str]]):
self.allow_dups = allow_dups
self.set_value(value)
def listify(self, value: T.Union[str, T.List[str]]) -> T.List[str]:
@staticmethod
def listify_value(value: T.Union[str, T.List[str]], shlex_split_args: bool = False) -> T.List[str]:
if isinstance(value, str):
if value.startswith('['):
try:
@ -266,7 +267,7 @@ class UserArrayOption(UserOption[T.List[str]]):
elif value == '':
newvalue = []
else:
if self.split_args:
if shlex_split_args:
newvalue = split_args(value)
else:
newvalue = [v.strip() for v in value.split(',')]
@ -276,6 +277,9 @@ class UserArrayOption(UserOption[T.List[str]]):
raise MesonException(f'"{value}" should be a string array, but it is not')
return newvalue
def listify(self, value: T.Any) -> T.List[T.Any]:
return self.listify_value(value, self.split_args)
def validate_value(self, value: T.Union[str, T.List[str]]) -> T.List[str]:
newvalue = self.listify(value)

@ -35,7 +35,7 @@ if T.TYPE_CHECKING:
import argparse
def array_arg(value: str) -> T.List[str]:
return UserArrayOption(None, value, allow_dups=True).value
return UserArrayOption.listify_value(value)
def validate_builddir(builddir: Path) -> None:
if not (builddir / 'meson-private' / 'coredata.dat').is_file():

Loading…
Cancel
Save