From e6fa8654ad9254d1c13d3a0fc4a84801cddd38b6 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 20 Sep 2018 14:55:55 +0300 Subject: [PATCH] YAPF --- platformio/__main__.py | 4 ++-- platformio/app.py | 4 ++-- platformio/builder/tools/pioide.py | 4 ++-- platformio/commands/lib.py | 33 +++++++++++++++--------------- platformio/commands/platform.py | 8 ++++---- platformio/commands/run.py | 13 ++++++------ platformio/commands/upgrade.py | 5 +++-- platformio/maintenance.py | 4 ++-- platformio/managers/lib.py | 18 ++++++++-------- platformio/managers/platform.py | 4 ++-- platformio/telemetry.py | 4 ++-- 11 files changed, 49 insertions(+), 52 deletions(-) diff --git a/platformio/__main__.py b/platformio/__main__.py index 1697b9d5..161acac3 100644 --- a/platformio/__main__.py +++ b/platformio/__main__.py @@ -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) diff --git a/platformio/app.py b/platformio/app.py index d4043164..57c126a9 100644 --- a/platformio/app.py +++ b/platformio/app.py @@ -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 diff --git a/platformio/builder/tools/pioide.py b/platformio/builder/tools/pioide.py index ec1134b2..01e800f0 100644 --- a/platformio/builder/tools/pioide.py +++ b/platformio/builder/tools/pioide.py @@ -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": diff --git a/platformio/commands/lib.py b/platformio/commands/lib.py index 358cff08..af107d3d 100644 --- a/platformio/commands/lib.py +++ b/platformio/commands/lib.py @@ -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( diff --git a/platformio/commands/platform.py b/platformio/commands/platform.py index 394803a1..4ccd65ff 100644 --- a/platformio/commands/platform.py +++ b/platformio/commands/platform.py @@ -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) diff --git a/platformio/commands/run.py b/platformio/commands/run.py index 4bb74482..3264ded0 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -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) diff --git a/platformio/commands/upgrade.py b/platformio/commands/upgrade.py index 7f415ad6..47b43304 100644 --- a/platformio/commands/upgrade.py +++ b/platformio/commands/upgrade.py @@ -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: diff --git a/platformio/maintenance.py b/platformio/maintenance.py index 2a1bf474..bafe4fa9 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -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") diff --git a/platformio/managers/lib.py b/platformio/managers/lib.py index ba81870a..0c6aa77d 100644 --- a/platformio/managers/lib.py +++ b/platformio/managers/lib.py @@ -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, diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index 210dd5f5..04c4d931 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -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")): diff --git a/platformio/telemetry.py b/platformio/telemetry.py index 769d58eb..90a0a150 100644 --- a/platformio/telemetry.py +++ b/platformio/telemetry.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()