diff options
author | Michael Hirsch, Ph.D <scivision@users.noreply.github.com> | 2019-11-18 00:04:33 -0500 |
---|---|---|
committer | Michael Hirsch, Ph.D <10931741+scivision@users.noreply.github.com> | 2020-02-06 12:54:38 -0500 |
commit | dcb7043403b227a8351b5864d5b856a2c81b69b9 (patch) | |
tree | 50565125fcfc80b76be5fe6c9786837b33f28395 /mesonbuild/modules/fs.py | |
parent | 4556343d95d8d64c7ab9bbbf1564b53940579f7f (diff) | |
download | meson-dcb7043403b227a8351b5864d5b856a2c81b69b9.zip meson-dcb7043403b227a8351b5864d5b856a2c81b69b9.tar.gz meson-dcb7043403b227a8351b5864d5b856a2c81b69b9.tar.bz2 |
fs: add expanduser method
this should help users specify leading `~` in various Meson options and variables
without refactoring lots of places inside Meson itself.
Diffstat (limited to 'mesonbuild/modules/fs.py')
-rw-r--r-- | mesonbuild/modules/fs.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/mesonbuild/modules/fs.py b/mesonbuild/modules/fs.py index 9b2cb8b..f006500 100644 --- a/mesonbuild/modules/fs.py +++ b/mesonbuild/modules/fs.py @@ -14,7 +14,7 @@ import typing as T import hashlib -from pathlib import Path, PurePath +from pathlib import Path, PurePath, PureWindowsPath from .. import mlog from . import ExtensionModule @@ -62,6 +62,13 @@ class FSModule(ExtensionModule): @stringArgs @noKwargs + def expanduser(self, state: 'ModuleState', args: T.Sequence[str], kwargs: dict) -> ModuleReturnValue: + if len(args) != 1: + raise MesonException('fs.expanduser takes exactly one argument.') + return ModuleReturnValue(str(Path(args[0]).expanduser()), []) + + @stringArgs + @noKwargs def is_absolute(self, state: 'ModuleState', args: T.Sequence[str], kwargs: dict) -> ModuleReturnValue: if len(args) != 1: raise MesonException('fs.is_absolute takes exactly one argument.') |