Skip to content

Commit

Permalink
Fix #556
Browse files Browse the repository at this point in the history
  • Loading branch information
rec committed Dec 27, 2014
1 parent 892b940 commit b071306
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
2 changes: 2 additions & 0 deletions code/python/echomesh/base/Yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
SEPARATOR_BASE = '---'
SEPARATOR = '\n%s\n' % SEPARATOR_BASE
PROPAGATE_EXCEPTIONS = not False
DEFAULT_INDENT = 4

def encode_one(item, **kwds):
kwds['indent'] = kwds.get('indent', DEFAULT_INDENT)
return yaml.safe_dump(item, **kwds)

def decode(s):
Expand Down
22 changes: 13 additions & 9 deletions code/python/echomesh/command/Show.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@
LOGGER = Log.logger(__name__)

SHOW_REGISTRY = Registry.Registry('show command')
DEFAULT_INDENT = ' '

def _indent(s, spaces=' '):
# TODO: remove in favor of _format.
def _indent(s, spaces=DEFAULT_INDENT):
return '\n'.join(spaces + i.strip() for i in s.split('\n'))

def _info(d, spaces=' '):
def _format(info, spaces=DEFAULT_INDENT):
s = Yaml.encode_one(info)
LOGGER.info('\n' + DEFAULT_INDENT + s.replace('\n', '\n' + DEFAULT_INDENT))

def _info(d, spaces=DEFAULT_INDENT):
s = 'none'
if d:
items = [(('%s%s:' % (spaces, k)), v)
Expand All @@ -41,7 +47,7 @@ def aliases(*_):
if al:
_info(al)
else:
LOGGER.info(' No aliases\n')
LOGGER.info(' No aliases\n')

def _all(echomesh_instance):
LOGGER.info('')
Expand All @@ -52,7 +58,7 @@ def _all(echomesh_instance):

def broadcast(echomesh_instance):
message = 'ON' if echomesh_instance.broadcasting() else 'off'
LOGGER.info(' Broadcast is %s\n', message)
LOGGER.info(' Broadcast is %s\n', message)

def _settings(_, *names):
settings = Settings.get_settings()
Expand All @@ -66,20 +72,18 @@ def _settings(_, *names):
LOGGER.error("Don't understand settings %s.", join_words(bad))
names -= bad
if names:
settings = dict((k, v) for k, v in settings.items() if k in names)
LOGGER.info('\n ' + Yaml.encode_one(settings).replace('\n', '\n '))
_format(dict((k, v) for k, v in settings.items() if k in names))
else:
LOGGER.info(' Possible settings are:\n ' +
LOGGER.info(' Possible settings are:\n ' +
join_words(settings.keys()))


def directories(_):
_info(Path.info())

def elements(echomesh_instance):
info = echomesh_instance.score_master.info()
if info:
_info(info)
_format(info)
else:
LOGGER.info(' No elements have been loaded into memory.\n')

Expand Down
2 changes: 1 addition & 1 deletion code/python/echomesh/element/ScoreMaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def handle(self, event):

def info(self):
with self.lock:
return dict(self.elements)
return dict((k, e.info()) for k, e, in self.elements.items())

def get_score(self, name):
with self.lock:
Expand Down

0 comments on commit b071306

Please sign in to comment.