-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
33 lines (26 loc) · 954 Bytes
/
example.py
File metadata and controls
33 lines (26 loc) · 954 Bytes
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
# example.py
import logging as log
from terminaltables3 import DoubleTable
from termaconfig import ConfigValidationError, TermaConfig
log.basicConfig(
level=log.INFO, format="%(asctime)s:%(name)s:%(levelname)s: %(message)s", datefmt="%H:%M:%S"
)
if __name__ == "__main__":
config_path = "example-config.toml"
spec_path = "example-spec.toml"
try:
config = TermaConfig(
config_path,
spec_path,
# tabletype can be any valid terminaltables3 class instance.
# Try passing another! Another valid option is AsciiTable
# SingleTable is used by default if none was provided.
tabletype=DoubleTable,
logging=False,
)
except ConfigValidationError:
print()
print("Errors are present in configuration. Exiting...")
exit()
print()
print("Here's the value of 'option1' in 'basic':", config["basic"]["option1"])