summaryrefslogtreecommitdiff
path: root/mesonbuild/modules
diff options
context:
space:
mode:
authorJouke Witteveen <j.witteveen@gmail.com>2025-07-14 16:12:30 +0200
committerJussi Pakkanen <jussi.pakkanen@mailbox.org>2025-07-24 16:04:48 +0300
commit277d7268be5c730823ddac0cacd651c826043918 (patch)
tree94ad1c0f23acf7b72ee1bec63e1ed1c670044abb /mesonbuild/modules
parent884fb4eefcfdb17a8434ac4a32600e120021641a (diff)
downloadmeson-277d7268be5c730823ddac0cacd651c826043918.tar.gz
Add suffix function to the fs module
Diffstat (limited to 'mesonbuild/modules')
-rw-r--r--mesonbuild/modules/fs.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/mesonbuild/modules/fs.py b/mesonbuild/modules/fs.py
index f6c1e1dc6..57a6b6dc8 100644
--- a/mesonbuild/modules/fs.py
+++ b/mesonbuild/modules/fs.py
@@ -44,7 +44,7 @@ class FSModule(ExtensionModule):
INFO = ModuleInfo('fs', '0.53.0')
- def __init__(self, interpreter: 'Interpreter') -> None:
+ def __init__(self, interpreter: Interpreter) -> None:
super().__init__(interpreter)
self.methods.update({
'as_posix': self.as_posix,
@@ -64,6 +64,7 @@ class FSModule(ExtensionModule):
'replace_suffix': self.replace_suffix,
'size': self.size,
'stem': self.stem,
+ 'suffix': self.suffix,
})
def _absolute_dir(self, state: ModuleState, arg: FileOrString) -> str:
@@ -225,6 +226,13 @@ class FSModule(ExtensionModule):
path = self._obj_to_pathstr('fs.name', args[0], state)
return os.path.splitext(os.path.basename(path))[0]
+ @noKwargs
+ @typed_pos_args('fs.suffix', (str, File, CustomTarget, CustomTargetIndex, BuildTarget))
+ @FeatureNew('fs.suffix', '1.9.0')
+ def suffix(self, state: ModuleState, args: T.Tuple[T.Union[FileOrString, BuildTargetTypes]], kwargs: T.Dict[str, T.Any]) -> str:
+ path = self._obj_to_pathstr('fs.suffix', args[0], state)
+ return os.path.splitext(path)[1]
+
@FeatureNew('fs.read', '0.57.0')
@typed_pos_args('fs.read', (str, File))
@typed_kwargs('fs.read', KwargInfo('encoding', str, default='utf-8'))