forked from platformio/platformio-core
YAPF
This commit is contained in:
@ -107,8 +107,8 @@ def configure():
|
||||
try:
|
||||
click_echo_origin[origin](*args, **kwargs)
|
||||
except IOError:
|
||||
(sys.stderr.write if kwargs.get("err") else
|
||||
sys.stdout.write)("%s\n" % (args[0] if args else ""))
|
||||
(sys.stderr.write if kwargs.get("err") else sys.stdout.write)(
|
||||
"%s\n" % (args[0] if args else ""))
|
||||
|
||||
click.echo = lambda *args, **kwargs: _safe_echo(0, *args, **kwargs)
|
||||
click.secho = lambda *args, **kwargs: _safe_echo(1, *args, **kwargs)
|
||||
|
@ -352,8 +352,8 @@ def get_cid():
|
||||
pass
|
||||
cid = str(
|
||||
uuid.UUID(
|
||||
bytes=hashlib.md5(str(_uid if _uid else uuid.getnode()))
|
||||
.digest()))
|
||||
bytes=hashlib.md5(str(_uid if _uid else uuid.getnode())).
|
||||
digest()))
|
||||
if "windows" in util.get_systype() or os.getuid() > 0:
|
||||
set_state_item("cid", cid)
|
||||
return cid
|
||||
|
@ -97,8 +97,8 @@ def _dump_defines(env):
|
||||
board_mcu = env.BoardConfig().get("build.mcu")
|
||||
if board_mcu:
|
||||
defines.append(
|
||||
str("__AVR_%s__" % board_mcu.upper()
|
||||
.replace("ATMEGA", "ATmega").replace("ATTINY", "ATtiny")))
|
||||
str("__AVR_%s__" % board_mcu.upper().replace(
|
||||
"ATMEGA", "ATmega").replace("ATTINY", "ATtiny")))
|
||||
|
||||
# built-in GCC marcos
|
||||
# if env.GetCompilerType() == "gcc":
|
||||
|
@ -307,13 +307,12 @@ def lib_builtin(storage, json_output):
|
||||
def lib_show(library, json_output):
|
||||
lm = LibraryManager()
|
||||
name, requirements, _ = lm.parse_pkg_uri(library)
|
||||
lib_id = lm.search_lib_id(
|
||||
{
|
||||
"name": name,
|
||||
"requirements": requirements
|
||||
},
|
||||
silent=json_output,
|
||||
interactive=not json_output)
|
||||
lib_id = lm.search_lib_id({
|
||||
"name": name,
|
||||
"requirements": requirements
|
||||
},
|
||||
silent=json_output,
|
||||
interactive=not json_output)
|
||||
lib = get_api_result("/lib/info/%d" % lib_id, cache_valid="1d")
|
||||
if json_output:
|
||||
return click.echo(json.dumps(lib))
|
||||
@ -423,16 +422,16 @@ def lib_stats(json_output):
|
||||
click.echo("-" * terminal_width)
|
||||
|
||||
def _print_lib_item(item):
|
||||
click.echo((printitemdate_tpl
|
||||
if "date" in item else printitem_tpl).format(
|
||||
name=click.style(item['name'], fg="cyan"),
|
||||
date=str(
|
||||
time.strftime("%c", util.parse_date(item['date']))
|
||||
if "date" in item else ""),
|
||||
url=click.style(
|
||||
"https://platformio.org/lib/show/%s/%s" %
|
||||
(item['id'], quote(item['name'])),
|
||||
fg="blue")))
|
||||
date = str(
|
||||
time.strftime("%c", util.parse_date(item['date'])) if "date" in
|
||||
item else "")
|
||||
url = click.style(
|
||||
"https://platformio.org/lib/show/%s/%s" % (item['id'],
|
||||
quote(item['name'])),
|
||||
fg="blue")
|
||||
click.echo(
|
||||
(printitemdate_tpl if "date" in item else printitem_tpl).format(
|
||||
name=click.style(item['name'], fg="cyan"), date=date, url=url))
|
||||
|
||||
def _print_tag_item(name):
|
||||
click.echo(
|
||||
|
@ -273,8 +273,8 @@ def platform_show(platform, json_output): # pylint: disable=too-many-branches
|
||||
if item['type']:
|
||||
click.echo("Type: %s" % item['type'])
|
||||
click.echo("Requirements: %s" % item['requirements'])
|
||||
click.echo("Installed: %s" % ("Yes" if item.get("version") else
|
||||
"No (optional)"))
|
||||
click.echo("Installed: %s" %
|
||||
("Yes" if item.get("version") else "No (optional)"))
|
||||
if "version" in item:
|
||||
click.echo("Version: %s" % item['version'])
|
||||
if "originalVersion" in item:
|
||||
@ -365,8 +365,8 @@ def platform_update(platforms, only_packages, only_check, json_output):
|
||||
if not pkg_dir:
|
||||
continue
|
||||
latest = pm.outdated(pkg_dir, requirements)
|
||||
if (not latest and not PlatformFactory.newPlatform(pkg_dir)
|
||||
.are_outdated_packages()):
|
||||
if (not latest and not PlatformFactory.newPlatform(pkg_dir).
|
||||
are_outdated_packages()):
|
||||
continue
|
||||
data = _get_installed_platform_data(
|
||||
pkg_dir, with_boards=False, expose_packages=False)
|
||||
|
@ -210,10 +210,10 @@ class EnvironmentProcessor(object):
|
||||
|
||||
if is_error or "piotest_processor" not in self.cmd_ctx.meta:
|
||||
print_header(
|
||||
"[%s] Took %.2f seconds" %
|
||||
((click.style("ERROR", fg="red", bold=True)
|
||||
if is_error else click.style(
|
||||
"SUCCESS", fg="green", bold=True)), time() - start_time),
|
||||
"[%s] Took %.2f seconds" % (
|
||||
(click.style("ERROR", fg="red", bold=True) if is_error else
|
||||
click.style("SUCCESS", fg="green", bold=True)),
|
||||
time() - start_time),
|
||||
is_error=is_error)
|
||||
|
||||
return not is_error
|
||||
@ -384,9 +384,8 @@ def print_summary(results, start_time):
|
||||
|
||||
print_header(
|
||||
"[%s] Took %.2f seconds" % (
|
||||
(click.style("SUCCESS", fg="green", bold=True)
|
||||
if successed else click.style("ERROR", fg="red", bold=True)),
|
||||
time() - start_time),
|
||||
(click.style("SUCCESS", fg="green", bold=True) if successed else
|
||||
click.style("ERROR", fg="red", bold=True)), time() - start_time),
|
||||
is_error=not successed)
|
||||
|
||||
|
||||
|
@ -102,8 +102,9 @@ def get_pip_package(to_develop):
|
||||
pkg_name = os.path.join(cache_dir, "piocoredevelop.zip")
|
||||
try:
|
||||
with open(pkg_name, "w") as fp:
|
||||
r = util.exec_command(
|
||||
["curl", "-fsSL", dl_url], stdout=fp, universal_newlines=True)
|
||||
r = util.exec_command(["curl", "-fsSL", dl_url],
|
||||
stdout=fp,
|
||||
universal_newlines=True)
|
||||
assert r['returncode'] == 0
|
||||
# check ZIP structure
|
||||
with ZipFile(pkg_name) as zp:
|
||||
|
@ -319,8 +319,8 @@ def check_internal_updates(ctx, what):
|
||||
if not app.get_setting("auto_update_" + what):
|
||||
click.secho("Please update them via ", fg="yellow", nl=False)
|
||||
click.secho(
|
||||
"`platformio %s update`" % ("lib --global" if what == "libraries"
|
||||
else "platform"),
|
||||
"`platformio %s update`" %
|
||||
("lib --global" if what == "libraries" else "platform"),
|
||||
fg="cyan",
|
||||
nl=False)
|
||||
click.secho(" command.\n", fg="yellow")
|
||||
|
@ -237,9 +237,8 @@ class LibraryManager(BasePkgManager):
|
||||
if not isinstance(values, list):
|
||||
values = [v.strip() for v in values.split(",") if v]
|
||||
for value in values:
|
||||
query.append(
|
||||
'%s:"%s"' % (key[:-1]
|
||||
if key.endswith("s") else key, value))
|
||||
query.append('%s:"%s"' %
|
||||
(key[:-1] if key.endswith("s") else key, value))
|
||||
|
||||
lib_info = None
|
||||
result = util.get_api_result(
|
||||
@ -337,13 +336,12 @@ class LibraryManager(BasePkgManager):
|
||||
force=False):
|
||||
_name, _requirements, _url = self.parse_pkg_uri(name, requirements)
|
||||
if not _url:
|
||||
name = "id=%d" % self.search_lib_id(
|
||||
{
|
||||
"name": _name,
|
||||
"requirements": _requirements
|
||||
},
|
||||
silent=silent,
|
||||
interactive=interactive)
|
||||
name = "id=%d" % self.search_lib_id({
|
||||
"name": _name,
|
||||
"requirements": _requirements
|
||||
},
|
||||
silent=silent,
|
||||
interactive=interactive)
|
||||
requirements = _requirements
|
||||
pkg_dir = BasePkgManager.install(
|
||||
self,
|
||||
|
@ -235,8 +235,8 @@ class PlatformFactory(object):
|
||||
name = pm.load_manifest(platform_dir)['name']
|
||||
|
||||
if not platform_dir:
|
||||
raise exception.UnknownPlatform(name if not requirements else
|
||||
"%s@%s" % (name, requirements))
|
||||
raise exception.UnknownPlatform(
|
||||
name if not requirements else "%s@%s" % (name, requirements))
|
||||
|
||||
platform_cls = None
|
||||
if isfile(join(platform_dir, "platform.py")):
|
||||
|
@ -112,8 +112,8 @@ class MeasurementProtocol(TelemetryBase):
|
||||
self['cd2'] = "Python/%s %s" % (platform.python_version(),
|
||||
platform.platform())
|
||||
# self['cd3'] = " ".join(_filter_args(sys.argv[1:]))
|
||||
self['cd4'] = 1 if (not util.is_ci()
|
||||
and (caller_id or not util.is_container())) else 0
|
||||
self['cd4'] = 1 if (not util.is_ci() and
|
||||
(caller_id or not util.is_container())) else 0
|
||||
if caller_id:
|
||||
self['cd5'] = caller_id.lower()
|
||||
|
||||
|
Reference in New Issue
Block a user