mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-31 18:44:27 +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
|
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")
|
@click.group(short_help="Manage PlatformIO settings")
|
||||||
def cli():
|
def cli():
|
||||||
pass
|
pass
|
||||||
@@ -28,25 +36,22 @@ def cli():
|
|||||||
@click.argument("name", required=False)
|
@click.argument("name", required=False)
|
||||||
def settings_get(name):
|
def settings_get(name):
|
||||||
tabular_data = []
|
tabular_data = []
|
||||||
for _name, _data in sorted(app.DEFAULT_SETTINGS.items()):
|
for key, options in sorted(app.DEFAULT_SETTINGS.items()):
|
||||||
if name and name != _name:
|
if name and name != key:
|
||||||
continue
|
continue
|
||||||
_value = app.get_setting(_name)
|
raw_value = app.get_setting(key)
|
||||||
|
formatted_value = format_value(raw_value)
|
||||||
|
|
||||||
_value_str = (str(_value)
|
if raw_value != options['value']:
|
||||||
if not isinstance(_value, string_types) else _value)
|
default_formatted_value = format_value(options['value'])
|
||||||
if isinstance(_value, bool):
|
formatted_value += "%s" % (
|
||||||
_value_str = "Yes" if _value else "No"
|
"\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(
|
tabular_data.append(
|
||||||
(click.style(_name, fg="cyan"), _value_str, _data['description']))
|
(click.style(key,
|
||||||
|
fg="cyan"), formatted_value, options['description']))
|
||||||
|
|
||||||
click.echo(
|
click.echo(
|
||||||
tabulate(tabular_data,
|
tabulate(tabular_data,
|
||||||
|
Reference in New Issue
Block a user