summaryrefslogtreecommitdiff
path: root/pygments/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'pygments/util.py')
-rw-r--r--pygments/util.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/pygments/util.py b/pygments/util.py
index 463f8468..01af01e6 100644
--- a/pygments/util.py
+++ b/pygments/util.py
@@ -33,6 +33,14 @@ class OptionError(Exception):
pass
+def get_flag_opt(options, optname, allowed, default=None):
+ string = options.get(optname, default)
+ if string not in allowed:
+ raise OptionError('Value for option %s must be one of %s' %
+ (optname, ', '.join(map(str, allowed))))
+ return string
+
+
def get_bool_opt(options, optname, default=None):
string = options.get(optname, default)
if isinstance(string, bool):