Fix naming from old scheme. Closes #4

Tom Wilson 6 years ago
parent ccd5a50892
commit 41946c69f7

@ -41,7 +41,7 @@ import toml
from abc import ABC, abstractmethod
from copy import deepcopy
from .freezedry import freezedryable, rehydrate
from preserve import preservable, restore
class InvalidConfigError(Exception):
@ -51,7 +51,7 @@ class InvalidConfigError(Exception):
# map directly to Dictionaries (Tables), and Lists (Arrays)
class _ConfigDefinition(ABC):
class _ConfigSpecification(ABC):
def __init__(self, default=None, optional=False, helptext=""):
self.default = default
self.optional = optional
@ -66,8 +66,8 @@ class _ConfigDefinition(ABC):
pass
@freezedryable
class BoolDef(_ConfigDefinition):
@preservable
class BoolDef(_ConfigSpecification):
def __init__(self, default=None, optional=False, helptext=""):
super().__init__(default, optional, helptext)
@ -76,8 +76,8 @@ class BoolDef(_ConfigDefinition):
raise InvalidConfigError("Config value must be a boolean")
@freezedryable
class IntDef(_ConfigDefinition):
@preservable
class IntDef(_ConfigSpecification):
def __init__(self, default=None, minval=None, maxval=None,
optional=False, helptext=""):
super().__init__(default, optional, helptext)
@ -95,8 +95,8 @@ class IntDef(_ConfigDefinition):
str(self.maxval))
@freezedryable
class StringDef(_ConfigDefinition):
@preservable
class StringDef(_ConfigSpecification):
def __init__(self, default="", minlength=None, maxlength=None,
optional=False, helptext=""):
super().__init__(default, optional, helptext)
@ -114,14 +114,14 @@ class StringDef(_ConfigDefinition):
str(self.maxlength))
@freezedryable
class DictDef(_ConfigDefinition):
@preservable
class DictDef(_ConfigSpecification):
def __init__(self, default=None, optional=False, helptext=""):
super().__init__(default, optional, helptext)
self.def_dict = {}
def add_def(self, name, newdef):
if not isinstance(newdef, _ConfigDefinition):
if not isinstance(newdef, _ConfigSpecification):
raise TypeError("Config definiton must be an instance of a "
"ConfigDefinition subclass")
if not isinstance(name, str):
@ -201,27 +201,27 @@ class _ListDefMixin():
return [self.default]
@freezedryable
@preservable
class BoolListDef(_ListDefMixin, BoolDef):
pass
@freezedryable
@preservable
class IntListDef(_ListDefMixin, IntDef):
pass
@freezedryable
@preservable
class StringListDef(_ListDefMixin, StringDef):
pass
@freezedryable
@preservable
class DictListDef(_ListDefMixin, DictDef):
pass
@freezedryable
@preservable
class ConfDefinition(DictDef):
pass
@ -419,4 +419,4 @@ def update_toml_message(filepath, message):
def gen_comment(string):
return '\n# shepherd_message: ' + '\n# '.join(string.replace('#', '').splitlines()) + '\n'
return '\n# config-spec_message: ' + '\n# '.join(string.replace('#', '').splitlines()) + '\n'

Loading…
Cancel
Save