diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-09-14 22:16:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-14 22:16:09 +0300 |
commit | 8fd8c16a879742a840b8f3a431539a261b8552ba (patch) | |
tree | 98d12ebbd5143ccba9cfac9e4e9591469bf9f076 /mesonbuild/interpreter.py | |
parent | 7d24f96d2dd4d4120cd619008454a0101531744d (diff) | |
parent | 09fdc7f815d8b6dede94a14a15a0c05fd1a621c1 (diff) | |
download | meson-8fd8c16a879742a840b8f3a431539a261b8552ba.zip meson-8fd8c16a879742a840b8f3a431539a261b8552ba.tar.gz meson-8fd8c16a879742a840b8f3a431539a261b8552ba.tar.bz2 |
Merge pull request #782 from tp-m/config-data-set-quoted
config data: add .set_quoted() convenience method to set quoted string
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r-- | mesonbuild/interpreter.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 9584950..316f8c4 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -187,6 +187,7 @@ class ConfigurationDataHolder(InterpreterObject): self.held_object = build.ConfigurationData() self.methods.update({'set': self.set_method, 'set10': self.set10_method, + 'set_quoted': self.set_quoted_method, 'has' : self.has_method, }) @@ -211,6 +212,13 @@ class ConfigurationDataHolder(InterpreterObject): (name, val) = self.validate_args(args) self.held_object.values[name] = val + def set_quoted_method(self, args, kwargs): + (name, val) = self.validate_args(args) + if not isinstance(val, str): + raise InterpreterException("Second argument to set_quoted must be a string.") + escaped_val = '\\"'.join(val.split('"')) + self.held_object.values[name] = '"' + escaped_val + '"' + def set10_method(self, args, kwargs): (name, val) = self.validate_args(args) if val: |