diff options
author | Tim-Philipp Müller <tim@centricular.com> | 2016-03-12 09:36:45 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2016-03-12 14:15:31 +0000 |
commit | 02e84df0105fb50ab82441b7ec64de149d23b7f9 (patch) | |
tree | 581b55d339a167f8dba3c493798624ba1458a73a /mesonbuild/interpreter.py | |
parent | 79537b54dbdaf467e425f6337d1c1566c4ccf26b (diff) | |
download | meson-02e84df0105fb50ab82441b7ec64de149d23b7f9.zip meson-02e84df0105fb50ab82441b7ec64de149d23b7f9.tar.gz meson-02e84df0105fb50ab82441b7ec64de149d23b7f9.tar.bz2 |
Add more string functions: contains(), to_upper() and to_lower()
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r-- | mesonbuild/interpreter.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 62b7fc0..37432a8 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2033,6 +2033,10 @@ class Interpreter(): return obj.strip() elif method_name == 'format': return self.format_string(obj, args) + elif method_name == 'to_upper': + return obj.upper() + elif method_name == 'to_lower': + return obj.lower() elif method_name == 'split': if len(posargs) > 1: raise InterpreterException('Split() must have at most one argument.') @@ -2043,12 +2047,14 @@ class Interpreter(): return obj.split(s) else: return obj.split() - elif method_name == 'startswith' or method_name == 'endswith': + elif method_name == 'startswith' or method_name == 'contains' or method_name == 'endswith': s = posargs[0] if not isinstance(s, str): raise InterpreterException('Argument must be a string.') if method_name == 'startswith': return obj.startswith(s) + elif method_name == 'contains': + return obj.find(s) >= 0 return obj.endswith(s) elif method_name == 'to_int': try: |