Skip to content

Commit a6f57a0

Browse files
committed
updated the configHelper module and the way of deffining the settings in the main add-on file.
1 parent 7afc3f6 commit a6f57a0

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

addon/globalPlugins/beepKeyboard/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212

1313
from ._configHelper import *
1414
class AppConfig(BaseConfig):
15-
def __init__(self):
16-
super().__init__('beepKeyboard')
15+
path = 'beepKeyboard'
1716

1817
beepUpperWithCapsLock = OptConfig('boolean(default=True)')
1918
beepCharacterWithShift = OptConfig('boolean(default=False)')

addon/globalPlugins/beepKeyboard/_configHelper.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def setConfigValue(path, optName, value):
2828
ops[optName] = value
2929

3030

31-
def registerConfig(clsSpec):
32-
AF = clsSpec()
31+
def registerConfig(clsSpec, path=None):
32+
AF = clsSpec(path)
3333
config.conf.spec[AF.path[0]] = AF.createSpec()
3434
AF.returnValue = True
3535
return AF
@@ -74,9 +74,13 @@ class BaseConfig:
7474
by default this value is False, to help to create the configuration spec first.
7575
Set it to true after creating this spec.
7676
"""
77-
78-
def __init__(self, path):
77+
path = None
78+
def __init__(self, path=None):
7979
self.returnValue = False
80+
if not path:
81+
path = self.__class__.path
82+
if not path:
83+
raise Exception("Path for the config is not defined")
8084
if isinstance(path, list):
8185
self.path = path
8286
else:

0 commit comments

Comments
 (0)