Move mopidy.utils.{log => formatting}.indent to break import cycle
This commit is contained in:
parent
e9e5330a14
commit
479ab249bb
@ -1,7 +1,7 @@
|
||||
import logging
|
||||
|
||||
from mopidy.frontends.mpd import dispatcher, protocol
|
||||
from mopidy.utils import log, network
|
||||
from mopidy.utils import formatting, network
|
||||
|
||||
logger = logging.getLogger('mopidy.frontends.mpd')
|
||||
|
||||
@ -36,7 +36,7 @@ class MpdSession(network.LineProtocol):
|
||||
logger.debug(
|
||||
u'Response to [%s]:%s from %s: %s',
|
||||
self.host, self.port, self.actor_urn,
|
||||
log.indent(self.terminator.join(response)))
|
||||
formatting.indent(self.terminator.join(response)))
|
||||
|
||||
self.send_lines(response)
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ import gst
|
||||
|
||||
import pykka
|
||||
|
||||
from mopidy.utils.log import indent
|
||||
from . import formatting
|
||||
|
||||
|
||||
def list_deps_optparse_callback(*args):
|
||||
@ -47,7 +47,7 @@ def format_dependency_list(adapters=None):
|
||||
os.path.dirname(dep_info['path'])))
|
||||
if 'other' in dep_info:
|
||||
lines.append(' Other: %s' % (
|
||||
indent(dep_info['other'])),)
|
||||
formatting.indent(dep_info['other'])),)
|
||||
return '\n'.join(lines)
|
||||
|
||||
|
||||
|
||||
8
mopidy/utils/formatting.py
Normal file
8
mopidy/utils/formatting.py
Normal file
@ -0,0 +1,8 @@
|
||||
def indent(string, places=4, linebreak='\n'):
|
||||
lines = string.split(linebreak)
|
||||
if len(lines) == 1:
|
||||
return string
|
||||
result = u''
|
||||
for line in lines:
|
||||
result += linebreak + ' ' * places + line
|
||||
return result
|
||||
@ -50,13 +50,3 @@ def setup_debug_logging_to_file():
|
||||
handler.setLevel(logging.DEBUG)
|
||||
root = logging.getLogger('')
|
||||
root.addHandler(handler)
|
||||
|
||||
|
||||
def indent(string, places=4, linebreak='\n'):
|
||||
lines = string.split(linebreak)
|
||||
if len(lines) == 1:
|
||||
return string
|
||||
result = u''
|
||||
for line in lines:
|
||||
result += linebreak + ' ' * places + line
|
||||
return result
|
||||
|
||||
@ -9,8 +9,7 @@ import pprint
|
||||
import sys
|
||||
|
||||
from mopidy import exceptions, SETTINGS_PATH, SETTINGS_FILE
|
||||
from mopidy.utils import log
|
||||
from mopidy.utils import path
|
||||
from mopidy.utils import formatting, path
|
||||
|
||||
logger = logging.getLogger('mopidy.utils.settings')
|
||||
|
||||
@ -76,7 +75,7 @@ class SettingsProxy(object):
|
||||
if self.get_errors():
|
||||
logger.error(
|
||||
u'Settings validation errors: %s',
|
||||
log.indent(self.get_errors_as_string()))
|
||||
formatting.indent(self.get_errors_as_string()))
|
||||
raise exceptions.SettingsError(u'Settings validation failed.')
|
||||
|
||||
def _read_missing_settings_from_stdin(self, current, runtime):
|
||||
@ -203,11 +202,11 @@ def format_settings_list(settings):
|
||||
default_value = settings.default.get(key)
|
||||
masked_value = mask_value_if_secret(key, value)
|
||||
lines.append(u'%s: %s' % (
|
||||
key, log.indent(pprint.pformat(masked_value), places=2)))
|
||||
key, formatting.indent(pprint.pformat(masked_value), places=2)))
|
||||
if value != default_value and default_value is not None:
|
||||
lines.append(
|
||||
u' Default: %s' %
|
||||
log.indent(pprint.pformat(default_value), places=4))
|
||||
formatting.indent(pprint.pformat(default_value), places=4))
|
||||
if errors.get(key) is not None:
|
||||
lines.append(u' Error: %s' % errors[key])
|
||||
return '\n'.join(lines)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user