Skip to content

Commit

Permalink
Revert 'combine' messages to match old format
Browse files Browse the repository at this point in the history
- Return 'SmartEnum' using enum value rather than repr format.
- Tweak typing around SmartEnum a few places that were inconstant.
  • Loading branch information
lowell80 committed Apr 20, 2022
1 parent 07e404d commit 8d4176e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ksconf/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ksconf.conf.parser import (ConfParserException, ParserConfig,
detect_by_bom, parse_conf, smart_write_conf,
write_conf)
from ksconf.consts import EXIT_CODE_BAD_CONF_FILE, EXIT_CODE_NO_SUCH_FILE, SMART_CREATE
from ksconf.consts import EXIT_CODE_BAD_CONF_FILE, EXIT_CODE_NO_SUCH_FILE, SMART_CREATE, SmartEnum
from ksconf.util import debug_traceback, memoize

__all__ = [
Expand Down Expand Up @@ -142,7 +142,7 @@ def load(self, profile=None):
data = parse_conf(self.stream, profile=parse_profile)
return data

def dump(self, data, **kwargs):
def dump(self, data, **kwargs) -> SmartEnum:
if not self.writable(): # pragma: no cover
raise ValueError(f"Unable to dump() to {self._type()} with mode '{self._mode}'")
# Feels like the right thing to do???? OR self._data = data
Expand Down
4 changes: 2 additions & 2 deletions ksconf/conf/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ksconf.conf.delta import compare_cfgs, show_diff
from ksconf.conf.parser import (GLOBAL_STANZA, ConfType, _extract_comments,
inject_section_comments, parse_conf, write_conf)
from ksconf.consts import SMART_UPDATE
from ksconf.consts import SMART_UPDATE, SmartEnum
from ksconf.util.file import relwalk

####################################################################################################
Expand Down Expand Up @@ -61,7 +61,7 @@ def merge_conf_dicts(*dicts):
def merge_conf_files(dest: ConfFileProxy,
configs: List[ConfFileProxy],
dry_run: bool = False,
banner_comment: str = None) -> ConfType:
banner_comment: str = None) -> SmartEnum:
# Parse all config files
cfgs = [conf.data for conf in configs]
newest_mtime = max(conf.mtime for conf in configs) if configs else None
Expand Down
3 changes: 3 additions & 0 deletions ksconf/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ class SmartEnum(Enum):
UPDATE = "updated"
NOCHANGE = "unchanged"

def __str__(self):
return self.value


# Legacy names
SMART_CREATE = SmartEnum.CREATE
Expand Down

0 comments on commit 8d4176e

Please sign in to comment.