From b50e2423ce9e2deb30f4a6489edc123f1290cfb1 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Wed, 31 Aug 2016 15:15:03 -0700 Subject: [PATCH] Add config option sanity checking --- pyqtgraph/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pyqtgraph/__init__.py b/pyqtgraph/__init__.py index 1630abc0..5b17297f 100644 --- a/pyqtgraph/__init__.py +++ b/pyqtgraph/__init__.py @@ -67,6 +67,11 @@ CONFIG_OPTIONS = { def setConfigOption(opt, value): + global CONFIG_OPTIONS + if opt not in CONFIG_OPTIONS: + raise KeyError('Unknown configuration option "%s"' % opt) + if opt == 'imageAxisOrder' and value not in ('row-major', 'col-major'): + raise ValueError('imageAxisOrder must be either "row-major" or "col-major"') CONFIG_OPTIONS[opt] = value def setConfigOptions(**opts): @@ -74,7 +79,8 @@ def setConfigOptions(**opts): Each keyword argument sets one global option. """ - CONFIG_OPTIONS.update(opts) + for k,v in opts.items(): + setConfigOption(k, v) def getConfigOption(opt): """Return the value of a single global configuration option.