From f276b2349a604ee84ea06ada55ae69e9ac4db4b2 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 14 Jun 2021 15:36:16 -0700 Subject: mesonlib: add rsplit and and maxsplit Since string has a maxsplit as well, we should implement that for polymorphism --- mesonbuild/mesonlib/universal.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mesonbuild/mesonlib/universal.py b/mesonbuild/mesonlib/universal.py index 94dc0a98c..160cc377d 100644 --- a/mesonbuild/mesonlib/universal.py +++ b/mesonbuild/mesonlib/universal.py @@ -422,8 +422,11 @@ class File(HoldableObject): def endswith(self, ending: str) -> bool: return self.fname.endswith(ending) - def split(self, s: str) -> T.List[str]: - return self.fname.split(s) + def split(self, s: str, maxsplit: int = -1) -> T.List[str]: + return self.fname.split(s, maxsplit=maxsplit) + + def rsplit(self, s: str, maxsplit: int = -1) -> T.List[str]: + return self.fname.rsplit(s, maxsplit=maxsplit) def __eq__(self, other: object) -> bool: if not isinstance(other, File): -- cgit v1.2.3