aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules/fs.py
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2019-11-24 19:39:13 -0500
committerXavier Claessens <xclaesse@gmail.com>2019-11-25 14:55:19 -0500
commita6f7a1d8c43b26a2607022e41ee3f1b8fe98e8d6 (patch)
tree40fa831a0903a54571cd266105eca3f1cd97ca8c /mesonbuild/modules/fs.py
parent696358957617dff59f40d5ff7befa9924982578c (diff)
downloadmeson-a6f7a1d8c43b26a2607022e41ee3f1b8fe98e8d6.zip
meson-a6f7a1d8c43b26a2607022e41ee3f1b8fe98e8d6.tar.gz
meson-a6f7a1d8c43b26a2607022e41ee3f1b8fe98e8d6.tar.bz2
fs: Add parent() and name() methods
Diffstat (limited to 'mesonbuild/modules/fs.py')
-rw-r--r--mesonbuild/modules/fs.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/mesonbuild/modules/fs.py b/mesonbuild/modules/fs.py
index 86861ae..6e1f5f7 100644
--- a/mesonbuild/modules/fs.py
+++ b/mesonbuild/modules/fs.py
@@ -118,6 +118,23 @@ class FSModule(ExtensionModule):
new = original.with_suffix(args[1])
return ModuleReturnValue(str(new), [])
+ @stringArgs
+ @noKwargs
+ def parent(self, state: 'ModuleState', args: typing.Sequence[str], kwargs: dict) -> ModuleReturnValue:
+ if len(args) != 1:
+ MesonException('method takes exactly one argument.')
+ original = PurePath(args[0])
+ new = original.parent
+ return ModuleReturnValue(str(new), [])
+
+ @stringArgs
+ @noKwargs
+ def name(self, state: 'ModuleState', args: typing.Sequence[str], kwargs: dict) -> ModuleReturnValue:
+ if len(args) != 1:
+ MesonException('method takes exactly one argument.')
+ original = PurePath(args[0])
+ new = original.name
+ return ModuleReturnValue(str(new), [])
def initialize(*args, **kwargs) -> FSModule:
return FSModule(*args, **kwargs)