blob: a158ecc502d0d292caddb3b7c72f7db3f44a26c7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import copy
from .. import Options
def backup_Options():
backup = {}
for name, value in vars(Options).items():
# we need a deep copy of _directive_defaults, because they can be changed
if name == '_directive_defaults':
value = copy.deepcopy(value)
backup[name] = value
return backup
def restore_Options(backup):
no_value = object()
for name, orig_value in backup.items():
if getattr(Options, name, no_value) != orig_value:
setattr(Options, name, orig_value)
# strip Options from new keys that might have been added:
for name in vars(Options).keys():
if name not in backup:
delattr(Options, name)
def check_global_options(expected_options, white_list=[]):
"""
returns error message of "" if check Ok
"""
no_value = object()
for name, orig_value in expected_options.items():
if name not in white_list:
if getattr(Options, name, no_value) != orig_value:
return "error in option " + name
return ""
|