mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 01:57:13 +02:00
Fixed an issue when printing settings and file path contains non-ASCII chars // Resolve #2934
This commit is contained in:
@ -19,6 +19,14 @@ from platformio import app
|
||||
from platformio.compat import string_types
|
||||
|
||||
|
||||
def format_value(raw):
|
||||
if isinstance(raw, bool):
|
||||
return "Yes" if raw else "No"
|
||||
if isinstance(raw, string_types):
|
||||
return raw
|
||||
return str(raw)
|
||||
|
||||
|
||||
@click.group(short_help="Manage PlatformIO settings")
|
||||
def cli():
|
||||
pass
|
||||
@ -28,25 +36,22 @@ def cli():
|
||||
@click.argument("name", required=False)
|
||||
def settings_get(name):
|
||||
tabular_data = []
|
||||
for _name, _data in sorted(app.DEFAULT_SETTINGS.items()):
|
||||
if name and name != _name:
|
||||
for key, options in sorted(app.DEFAULT_SETTINGS.items()):
|
||||
if name and name != key:
|
||||
continue
|
||||
_value = app.get_setting(_name)
|
||||
raw_value = app.get_setting(key)
|
||||
formatted_value = format_value(raw_value)
|
||||
|
||||
_value_str = (str(_value)
|
||||
if not isinstance(_value, string_types) else _value)
|
||||
if isinstance(_value, bool):
|
||||
_value_str = "Yes" if _value else "No"
|
||||
if raw_value != options['value']:
|
||||
default_formatted_value = format_value(options['value'])
|
||||
formatted_value += "%s" % (
|
||||
"\n" if len(default_formatted_value) > 10 else " ")
|
||||
formatted_value += "[%s]" % click.style(default_formatted_value,
|
||||
fg="yellow")
|
||||
|
||||
if _value != _data['value']:
|
||||
_defvalue_str = str(_data['value'])
|
||||
if isinstance(_data['value'], bool):
|
||||
_defvalue_str = "Yes" if _data['value'] else "No"
|
||||
_value_str = click.style(_value_str, fg="yellow")
|
||||
_value_str += "%s[%s]" % ("\n" if len(_value_str) > 10 else " ",
|
||||
_defvalue_str)
|
||||
tabular_data.append(
|
||||
(click.style(_name, fg="cyan"), _value_str, _data['description']))
|
||||
(click.style(key,
|
||||
fg="cyan"), formatted_value, options['description']))
|
||||
|
||||
click.echo(
|
||||
tabulate(tabular_data,
|
||||
|
Reference in New Issue
Block a user