aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-01-05 18:17:47 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2017-01-06 14:01:45 -0500
commit00f62d07558f74f57972f35eb9508d0a78019cc2 (patch)
tree92c1f26bd85b7e3ae6665a763a7225b630ff9ec3 /mesonbuild/interpreter.py
parent8f3616e72e996414e6dfc368e8a540e6a52af506 (diff)
downloadmeson-00f62d07558f74f57972f35eb9508d0a78019cc2.zip
meson-00f62d07558f74f57972f35eb9508d0a78019cc2.tar.gz
meson-00f62d07558f74f57972f35eb9508d0a78019cc2.tar.bz2
Can get values in ConfigurationData objects.
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r--mesonbuild/interpreter.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index ec82ec9..67ee658 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1,4 +1,4 @@
-# Copyright 2012-2016 The Meson development team
+# Copyright 2012-2017 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -163,6 +163,7 @@ class ConfigurationDataHolder(MutableInterpreterObject):
'set10': self.set10_method,
'set_quoted': self.set_quoted_method,
'has': self.has_method,
+ 'get': self.get_method,
})
def is_used(self):
@@ -207,6 +208,16 @@ class ConfigurationDataHolder(MutableInterpreterObject):
def has_method(self, args, kwargs):
return args[0] in self.held_object.values
+ def get_method(self, args, kwargs):
+ if len(args) < 1 or len(args) > 2:
+ raise InterpreterException('Get method takes one or two arguments.')
+ name = args[0]
+ if name in self.held_object:
+ return self.held_object.get(name)[0]
+ if len(args) > 1:
+ return args[1]
+ raise InterpreterException('Entry %s not in configuration data.' % name)
+
def get(self, name):
return self.held_object.values[name] # (val, desc)