aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-03-12 16:42:40 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2016-03-12 16:42:40 +0200
commit2afc1dd497e78478faace68f14471ed9b3942d1f (patch)
tree3474088b8690d4dc8b8eb95a85a0f8babe207c38 /mesonbuild/interpreter.py
parent49418cfe8ab1f42fa28ca9f408f60050bf56c5dc (diff)
parent3c8468cd4d90f5072934e849078298e70dd1ddfc (diff)
downloadmeson-2afc1dd497e78478faace68f14471ed9b3942d1f.zip
meson-2afc1dd497e78478faace68f14471ed9b3942d1f.tar.gz
meson-2afc1dd497e78478faace68f14471ed9b3942d1f.tar.bz2
Merge pull request #443 from tp-m/more-string-funcs
Add more string funcs: to_upper(), to_lower(), contains() and underscorify()
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r--mesonbuild/interpreter.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 62b7fc0..14f20e7 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -2033,6 +2033,12 @@ 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 == 'underscorify':
+ return re.sub(r'[^a-zA-Z0-9]', '_', obj)
elif method_name == 'split':
if len(posargs) > 1:
raise InterpreterException('Split() must have at most one argument.')
@@ -2043,12 +2049,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: