-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleConfig.py
More file actions
56 lines (42 loc) · 1.95 KB
/
ExampleConfig.py
File metadata and controls
56 lines (42 loc) · 1.95 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# -*- coding: utf-8 -*-
"""
Author(s): Christoph Schmidt <christoph.schmidt@tugraz.at>
Created: 2023-10-19 12:35
Package Version:
Description:
"""
import sys
sys.path.append("../src")
import confPy6 as cfg
class SecondConfig(cfg.ConfigNode):
def __init__(self, internal_log=True) -> None:
# Call the base class (important!)
super().__init__(internal_log=internal_log)
# Some fields
# Create a field of type int. Set a default value, a friendly name and a description
self.test_int: cfg.Field[int] = cfg.Field(1,
friendly_name="My Test Int",
description="This is just an integer")
self.register()
class ApplicationConfig(cfg.ConfigNode):
def __init__(self, internal_log=True) -> None:
# Call the base class (important!)
super().__init__(internal_log=internal_log)
# Some fields
# Create a field of type int. Set a default value, a friendly name and a description
self.counter: cfg.Field[int] = cfg.Field(1,
friendly_name="My Counter",
description="This is just an integer")
self.version: cfg.Field[str] = cfg.Field("v1.0",
friendly_name="Version",
description="The version")
# You can also omit the friendly name and description
self.check: cfg.Field[bool] = cfg.Field(False)
# Some other fields
# Also possible to create a field of type list
self.my_tuple: cfg.Field[tuple] = cfg.Field((1, 2))
self.any_list: cfg.Field[list] = cfg.Field([1, 2])
# Even a nested config is possible
self.second_config: SecondConfig = SecondConfig()
# Don't forget to register the fields (important!)
self.register()