From 4d1a135d76c4c6f22d2c0b1f95c92dfe722dbfdf Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 5 Jun 2017 16:05:05 +0300 Subject: [PATCH] Apply YAPF --- platformio/app.py | 6 ++- platformio/builder/main.py | 3 +- platformio/builder/tools/pioide.py | 27 ++++++++----- platformio/builder/tools/piolib.py | 27 +++++++------ platformio/builder/tools/piomisc.py | 8 ++-- platformio/builder/tools/pioplatform.py | 3 +- platformio/builder/tools/pioupload.py | 8 ++-- platformio/builder/tools/platformio.py | 7 ++-- platformio/commands/init.py | 7 ++-- platformio/commands/lib.py | 29 ++++++------- platformio/commands/platform.py | 4 +- platformio/commands/run.py | 26 ++++++------ platformio/downloader.py | 5 ++- platformio/ide/projectgenerator.py | 24 +++++++---- platformio/maintenance.py | 54 +++++++++++++------------ platformio/managers/lib.py | 15 +++---- platformio/managers/package.py | 26 ++++++------ platformio/managers/platform.py | 21 +++++----- platformio/telemetry.py | 5 ++- platformio/util.py | 20 ++++----- platformio/vcsclient.py | 8 ++-- 21 files changed, 183 insertions(+), 150 deletions(-) diff --git a/platformio/app.py b/platformio/app.py index 704db38a..d4bfdb3e 100644 --- a/platformio/app.py +++ b/platformio/app.py @@ -64,7 +64,8 @@ DEFAULT_SETTINGS = { "description": ("Telemetry service (Yes/No)"), - "value": True + "value": + True } } @@ -333,7 +334,8 @@ def set_session_var(name, value): def is_disabled_progressbar(): return any([ - get_session_var("force_option"), util.is_ci(), + get_session_var("force_option"), + util.is_ci(), getenv("PLATFORMIO_DISABLE_PROGRESSBAR") == "true" ]) diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 31fc8076..679236bc 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -89,7 +89,8 @@ DEFAULT_ENV_OPTIONS = dict( BUILDSRC_DIR=join("$BUILD_DIR", "src"), BUILDTEST_DIR=join("$BUILD_DIR", "test"), LIBSOURCE_DIRS=[ - util.get_projectlib_dir(), util.get_projectlibdeps_dir(), + util.get_projectlib_dir(), + util.get_projectlibdeps_dir(), join("$PIOHOME_DIR", "lib") ], PROGNAME="program", diff --git a/platformio/builder/tools/pioide.py b/platformio/builder/tools/pioide.py index d0b27286..e05b2d79 100644 --- a/platformio/builder/tools/pioide.py +++ b/platformio/builder/tools/pioide.py @@ -74,17 +74,22 @@ def DumpIDEData(env): data = { "libsource_dirs": [env.subst(l) for l in env.get("LIBSOURCE_DIRS", [])], - "defines": dump_defines(env), - "includes": dump_includes(env), - "cc_flags": env.subst(LINTCCOM), - "cxx_flags": env.subst(LINTCXXCOM), - "cc_path": util.where_is_program( - env.subst("$CC"), env.subst("${ENV['PATH']}")), - "cxx_path": util.where_is_program( - env.subst("$CXX"), env.subst("${ENV['PATH']}")), - "gdb_path": util.where_is_program( - env.subst("$GDB"), env.subst("${ENV['PATH']}")), - "prog_path": env.subst("$PROG_PATH") + "defines": + dump_defines(env), + "includes": + dump_includes(env), + "cc_flags": + env.subst(LINTCCOM), + "cxx_flags": + env.subst(LINTCXXCOM), + "cc_path": + util.where_is_program(env.subst("$CC"), env.subst("${ENV['PATH']}")), + "cxx_path": + util.where_is_program(env.subst("$CXX"), env.subst("${ENV['PATH']}")), + "gdb_path": + util.where_is_program(env.subst("$GDB"), env.subst("${ENV['PATH']}")), + "prog_path": + env.subst("$PROG_PATH") } env_ = env.Clone() diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 2db543a6..8f7a1f52 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -39,8 +39,8 @@ class LibBuilderFactory(object): clsname = "PlatformIOLibBuilder" else: used_frameworks = LibBuilderFactory.get_used_frameworks(env, path) - common_frameworks = (set(env.get("PIOFRAMEWORK", [])) & - set(used_frameworks)) + common_frameworks = ( + set(env.get("PIOFRAMEWORK", [])) & set(used_frameworks)) if common_frameworks: clsname = "%sLibBuilder" % list(common_frameworks)[0].title() elif used_frameworks: @@ -134,8 +134,10 @@ class LibBuilderBase(object): @property def src_filter(self): return piotool.SRC_FILTER_DEFAULT + [ - "-" % os.sep, "-" % os.sep, "-" % - os.sep, "-" % os.sep + "-" % os.sep, + "-" % os.sep, + "-" % os.sep, + "-" % os.sep ] @property @@ -247,8 +249,9 @@ class LibBuilderBase(object): if (key in item and not self.items_in_list(self.env[env_key], item[key])): if self.verbose: - sys.stderr.write("Skip %s incompatible dependency %s\n" - % (key[:-1], item)) + sys.stderr.write( + "Skip %s incompatible dependency %s\n" % (key[:-1], + item)) skip = True if skip: continue @@ -337,8 +340,8 @@ class LibBuilderBase(object): if _already_depends(lb): if self.verbose: sys.stderr.write("Warning! Circular dependencies detected " - "between `%s` and `%s`\n" % - (self.path, lb.path)) + "between `%s` and `%s`\n" % (self.path, + lb.path)) self._circular_deps.append(lb) elif lb not in self._depbuilders: self._depbuilders.append(lb) @@ -604,14 +607,14 @@ def GetLibBuilders(env): # pylint: disable=too-many-branches if compat_mode > 1 and not lb.is_platforms_compatible( env['PIOPLATFORM']): if verbose: - sys.stderr.write("Platform incompatible library %s\n" % - lb.path) + sys.stderr.write( + "Platform incompatible library %s\n" % lb.path) return False if compat_mode > 0 and "PIOFRAMEWORK" in env and \ not lb.is_frameworks_compatible(env.get("PIOFRAMEWORK", [])): if verbose: - sys.stderr.write("Framework incompatible library %s\n" % - lb.path) + sys.stderr.write( + "Framework incompatible library %s\n" % lb.path) return False return True diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index 1f689b91..f716347f 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -89,8 +89,8 @@ class InoToCPPConverter(object): self.env.Execute( self.env.VerboseAction( '$CXX -o "{0}" -x c++ -fpreprocessed -dD -E "{1}"'.format( - out_file, tmp_path), "Converting " + basename( - out_file[:-4]))) + out_file, + tmp_path), "Converting " + basename(out_file[:-4]))) atexit.register(_delete_file, tmp_path) return isfile(out_file) @@ -139,8 +139,8 @@ class InoToCPPConverter(object): prototypes = [] reserved_keywords = set(["if", "else", "while"]) for match in self.PROTOTYPE_RE.finditer(contents): - if (set([match.group(2).strip(), match.group(3).strip()]) & - reserved_keywords): + if (set([match.group(2).strip(), + match.group(3).strip()]) & reserved_keywords): continue prototypes.append(match) return prototypes diff --git a/platformio/builder/tools/pioplatform.py b/platformio/builder/tools/pioplatform.py index 3fbe607e..9be56410 100644 --- a/platformio/builder/tools/pioplatform.py +++ b/platformio/builder/tools/pioplatform.py @@ -81,7 +81,8 @@ def LoadPioPlatform(env, variables): board_config = env.BoardConfig() for k in variables.keys(): if (k in env or - not any([k.startswith("BOARD_"), k.startswith("UPLOAD_")])): + not any([k.startswith("BOARD_"), + k.startswith("UPLOAD_")])): continue _opt, _val = k.lower().split("_", 1) if _opt == "board": diff --git a/platformio/builder/tools/pioupload.py b/platformio/builder/tools/pioupload.py index e666276c..4492b464 100644 --- a/platformio/builder/tools/pioupload.py +++ b/platformio/builder/tools/pioupload.py @@ -107,8 +107,8 @@ def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument def _look_for_mbed_disk(): msdlabels = ("mbed", "nucleo", "frdm", "microbit") for item in util.get_logicaldisks(): - if item['disk'].startswith("/net") or not _is_match_pattern( - item['disk']): + if item['disk'].startswith( + "/net") or not _is_match_pattern(item['disk']): continue mbed_pages = [ join(item['disk'], n) for n in ("mbed.htm", "mbed.html") @@ -201,8 +201,8 @@ def CheckUploadSize(_, target, source, env): # pylint: disable=W0613,W0621 if used_size > max_size: sys.stderr.write("Error: The program size (%d bytes) is greater " - "than maximum allowed (%s bytes)\n" % - (used_size, max_size)) + "than maximum allowed (%s bytes)\n" % (used_size, + max_size)) env.Exit(1) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 3998418d..fffb8e40 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -35,9 +35,10 @@ SRC_FILTER_DEFAULT = ["+<*>", "-<.git%s>" % sep, "-" % sep] def BuildProgram(env): def _append_pio_macros(): - env.AppendUnique(CPPDEFINES=[( - "PLATFORMIO", - int("{0:02d}{1:02d}{2:02d}".format(*pioversion_to_intstr())))]) + env.AppendUnique(CPPDEFINES=[ + ("PLATFORMIO", + int("{0:02d}{1:02d}{2:02d}".format(*pioversion_to_intstr()))) + ]) _append_pio_macros() diff --git a/platformio/commands/init.py b/platformio/commands/init.py index 230594f1..564010a1 100644 --- a/platformio/commands/init.py +++ b/platformio/commands/init.py @@ -84,8 +84,8 @@ def cli( click.style(project_dir, fg="cyan")) click.echo("%s - Project Configuration File" % click.style( "platformio.ini", fg="cyan")) - click.echo("%s - Put your source files here" % click.style( - "src", fg="cyan")) + click.echo( + "%s - Put your source files here" % click.style("src", fg="cyan")) click.echo("%s - Put here project specific (private) libraries" % click.style("lib", fg="cyan")) @@ -297,7 +297,8 @@ def fill_project_envs(ctx, project_dir, board_ids, project_option, env_prefix, config = util.load_project_config(project_dir) for section in config.sections(): cond = [ - section.startswith("env:"), config.has_option(section, "board") + section.startswith("env:"), + config.has_option(section, "board") ] if all(cond): used_boards.append(config.get(section, "board")) diff --git a/platformio/commands/lib.py b/platformio/commands/lib.py index c9862ace..5a4c9fbc 100644 --- a/platformio/commands/lib.py +++ b/platformio/commands/lib.py @@ -366,8 +366,9 @@ def lib_show(library, json_output): for v in lib['versions'] ])) blocks.append(("Unique Downloads", [ - "Today: %s" % lib['dlstats']['day'], "Week: %s" % - lib['dlstats']['week'], "Month: %s" % lib['dlstats']['month'] + "Today: %s" % lib['dlstats']['day'], + "Week: %s" % lib['dlstats']['week'], + "Month: %s" % lib['dlstats']['month'] ])) for (title, rows) in blocks: @@ -418,16 +419,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( - arrow.get(item['date']).humanize() if "date" in item else ""), - url=click.style( - "http://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=str( + arrow.get(item['date']).humanize() + if "date" in item else ""), + url=click.style( + "http://platformio.org/lib/show/%s/%s" % + (item['id'], quote(item['name'])), + fg="blue"))) def _print_tag_item(name): click.echo( @@ -457,8 +458,8 @@ def lib_stats(json_output): _print_tag_item(item) click.echo() - for key, title in (("dlday", "Today"), ("dlweek", "Week"), - ("dlmonth", "Month")): + for key, title in (("dlday", "Today"), ("dlweek", "Week"), ("dlmonth", + "Month")): _print_title("Featured: " + title) _print_header(with_date=False) for item in result.get(key, []): diff --git a/platformio/commands/platform.py b/platformio/commands/platform.py index 0e13610c..ed9e17f8 100644 --- a/platformio/commands/platform.py +++ b/platformio/commands/platform.py @@ -269,8 +269,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: diff --git a/platformio/commands/run.py b/platformio/commands/run.py index 4a02e8bc..077460db 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -169,11 +169,12 @@ class EnvironmentProcessor(object): if not self.silent: click.echo("[%s] Processing %s (%s)" % - (datetime.now().strftime("%c"), click.style( - self.name, fg="cyan", bold=True), "; ".join([ - "%s: %s" % (k, v.replace("\n", ", ")) - for k, v in self.options.items() - ]))) + (datetime.now().strftime("%c"), + click.style(self.name, fg="cyan", bold=True), + "; ".join([ + "%s: %s" % (k, v.replace("\n", ", ")) + for k, v in self.options.items() + ]))) click.secho("-" * terminal_width, bold=True) self.options = self._validate_options(self.options) @@ -185,10 +186,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 @@ -356,9 +357,10 @@ def print_summary(results, start_time): err=status is False) 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), + "[%s] Took %.2f seconds" % + ((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/downloader.py b/platformio/downloader.py index f4feaa61..986d3283 100644 --- a/platformio/downloader.py +++ b/platformio/downloader.py @@ -38,8 +38,9 @@ class FileDownloader(object): disposition = self._request.headers.get("content-disposition") if disposition and "filename=" in disposition: - self._fname = disposition[disposition.index("filename=") + - 9:].replace('"', "").replace("'", "") + self._fname = disposition[ + disposition.index("filename=") + 9:].replace('"', "").replace( + "'", "") self._fname = self._fname.encode("utf8") else: self._fname = url.split("/")[-1] diff --git a/platformio/ide/projectgenerator.py b/platformio/ide/projectgenerator.py index b03cc772..c12d4731 100644 --- a/platformio/ide/projectgenerator.py +++ b/platformio/ide/projectgenerator.py @@ -151,16 +151,24 @@ class ProjectGenerator(object): self._tplvars.update(self.get_project_env()) self._tplvars.update(self.get_project_build_data()) self._tplvars.update({ - "project_name": self.get_project_name(), - "src_files": self.get_src_files(), - "user_home_dir": abspath(expanduser("~")), - "project_dir": self.project_dir, - "project_src_dir": self.project_src_dir, - "systype": util.get_systype(), + "project_name": + self.get_project_name(), + "src_files": + self.get_src_files(), + "user_home_dir": + abspath(expanduser("~")), + "project_dir": + self.project_dir, + "project_src_dir": + self.project_src_dir, + "systype": + util.get_systype(), "platformio_path": self._fix_os_path(util.where_is_program("platformio")), - "env_pathsep": os.pathsep, - "env_path": self._fix_os_path(os.getenv("PATH")) + "env_pathsep": + os.pathsep, + "env_path": + self._fix_os_path(os.getenv("PATH")) }) @staticmethod diff --git a/platformio/maintenance.py b/platformio/maintenance.py index 0900b0b5..b51fbdf8 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -95,12 +95,12 @@ class Upgrader(object): self.to_version = semantic_version.Version.coerce( util.pepver_to_semver(to_version)) - self._upgraders = [ - (semantic_version.Version("3.0.0-a.1"), self._upgrade_to_3_0_0), - (semantic_version.Version("3.0.0-b.11"), - self._upgrade_to_3_0_0b11), - (semantic_version.Version("3.4.0-a.9"), self._update_dev_platforms) - ] + self._upgraders = [(semantic_version.Version("3.0.0-a.1"), + self._upgrade_to_3_0_0), + (semantic_version.Version("3.0.0-b.11"), + self._upgrade_to_3_0_0b11), + (semantic_version.Version("3.4.0-a.9"), + self._update_dev_platforms)] def run(self, ctx): if self.from_version > self.to_version: @@ -170,8 +170,8 @@ def after_upgrade(ctx): util.pepver_to_semver(__version__)): click.secho("*" * terminal_width, fg="yellow") click.secho( - "Obsolete PIO Core v%s is used (previous was %s)" % - (__version__, last_version), + "Obsolete PIO Core v%s is used (previous was %s)" % (__version__, + last_version), fg="yellow") click.secho( "Please remove multiple PIO Cores from a system:", fg="yellow") @@ -205,23 +205,25 @@ def after_upgrade(ctx): # PlatformIO banner click.echo("*" * terminal_width) - click.echo("If you like %s, please:" % (click.style( - "PlatformIO", fg="cyan"))) + click.echo("If you like %s, please:" % + (click.style("PlatformIO", fg="cyan"))) click.echo("- %s us on Twitter to stay up-to-date " - "on the latest project news > %s" % (click.style( - "follow", fg="cyan"), click.style( - "https://twitter.com/PlatformIO_Org", fg="cyan"))) - click.echo("- %s it on GitHub > %s" % - (click.style("star", fg="cyan"), click.style( - "https://github.com/platformio/platformio", fg="cyan"))) + "on the latest project news > %s" % + (click.style("follow", fg="cyan"), + click.style("https://twitter.com/PlatformIO_Org", fg="cyan"))) + click.echo( + "- %s it on GitHub > %s" % + (click.style("star", fg="cyan"), + click.style("https://github.com/platformio/platformio", fg="cyan"))) if not getenv("PLATFORMIO_IDE"): - click.echo("- %s PlatformIO IDE for IoT development > %s" % - (click.style("try", fg="cyan"), click.style( - "http://platformio.org/platformio-ide", fg="cyan"))) + click.echo( + "- %s PlatformIO IDE for IoT development > %s" % + (click.style("try", fg="cyan"), + click.style("http://platformio.org/platformio-ide", fg="cyan"))) if not util.is_ci(): - click.echo("- %s us with PlatformIO Plus > %s" % (click.style( - "support", fg="cyan"), click.style( - "https://pioplus.com", fg="cyan"))) + click.echo("- %s us with PlatformIO Plus > %s" % + (click.style("support", fg="cyan"), + click.style("https://pioplus.com", fg="cyan"))) click.echo("*" * terminal_width) click.echo("") @@ -284,8 +286,8 @@ def check_internal_updates(ctx, what): if manifest['name'] in outdated_items: continue conds = [ - pm.outdated(manifest['__pkg_dir']), what == "platforms" and - PlatformFactory.newPlatform( + pm.outdated(manifest['__pkg_dir']), + what == "platforms" and PlatformFactory.newPlatform( manifest['__pkg_dir']).are_outdated_packages() ] if any(conds): @@ -299,8 +301,8 @@ def check_internal_updates(ctx, what): click.echo("") click.echo("*" * terminal_width) click.secho( - "There are the new updates for %s (%s)" % - (what, ", ".join(outdated_items)), + "There are the new updates for %s (%s)" % (what, + ", ".join(outdated_items)), fg="yellow") if not app.get_setting("auto_update_" + what): diff --git a/platformio/managers/lib.py b/platformio/managers/lib.py index fea2a62a..5ce9fe99 100644 --- a/platformio/managers/lib.py +++ b/platformio/managers/lib.py @@ -226,9 +226,9 @@ class LibraryManager(BasePkgManager): cache_valid="30d") assert dl_data - return self._install_from_url( - name, dl_data['url'].replace("http://", "https://") - if app.get_setting("enable_ssl") else dl_data['url'], requirements) + return self._install_from_url(name, dl_data['url'].replace( + "http://", "https://") if app.get_setting("enable_ssl") else + dl_data['url'], requirements) def install( # pylint: disable=arguments-differ self, @@ -239,8 +239,8 @@ class LibraryManager(BasePkgManager): interactive=False): pkg_dir = None try: - _name, _requirements, _url = self.parse_pkg_input(name, - requirements) + _name, _requirements, _url = self.parse_pkg_input( + name, requirements) if not _url: name = "id=%d" % self.get_pkg_id_by_name( _name, @@ -309,8 +309,9 @@ 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( diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 5d4386a6..9810a3d5 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -418,8 +418,8 @@ class PkgInstallerMixin(object): # package should satisfy requirements if requirements: mismatch_error = ( - "Package version %s doesn't satisfy requirements %s" % ( - tmp_manifest['version'], requirements)) + "Package version %s doesn't satisfy requirements %s" % + (tmp_manifest['version'], requirements)) try: assert tmp_semver and tmp_semver in semantic_version.Spec( requirements), mismatch_error @@ -651,18 +651,18 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): if isdir(package): pkg_dir = package else: - name, requirements, url = self.parse_pkg_input(package, - requirements) + name, requirements, url = self.parse_pkg_input( + package, requirements) pkg_dir = self.get_package_dir(name, requirements, url) if not pkg_dir: - raise exception.UnknownPackage("%s @ %s" % - (package, requirements or "*")) + raise exception.UnknownPackage("%s @ %s" % (package, + requirements or "*")) manifest = self.load_manifest(pkg_dir) click.echo( - "Uninstalling %s @ %s: \t" % (click.style( - manifest['name'], fg="cyan"), manifest['version']), + "Uninstalling %s @ %s: \t" % + (click.style(manifest['name'], fg="cyan"), manifest['version']), nl=False) if islink(pkg_dir): @@ -674,9 +674,9 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): # unfix package with the same name pkg_dir = self.get_package_dir(manifest['name']) if pkg_dir and "@" in pkg_dir: - os.rename( - pkg_dir, - join(self.package_dir, self.get_install_dirname(manifest))) + os.rename(pkg_dir, + join(self.package_dir, + self.get_install_dirname(manifest))) self.cache_reset() click.echo("[%s]" % click.style("OK", fg="green")) @@ -699,8 +699,8 @@ class BasePkgManager(PkgRepoMixin, PkgInstallerMixin): pkg_dir = self.get_package_dir(*self.parse_pkg_input(package)) if not pkg_dir: - raise exception.UnknownPackage("%s @ %s" % - (package, requirements or "*")) + raise exception.UnknownPackage("%s @ %s" % (package, + requirements or "*")) manifest = self.load_manifest(pkg_dir) name = manifest['name'] diff --git a/platformio/managers/platform.py b/platformio/managers/platform.py index e5f8f47e..015d9504 100644 --- a/platformio/managers/platform.py +++ b/platformio/managers/platform.py @@ -84,8 +84,8 @@ class PlatformManager(BasePkgManager): if isdir(package): pkg_dir = package else: - name, requirements, url = self.parse_pkg_input(package, - requirements) + name, requirements, url = self.parse_pkg_input( + package, requirements) pkg_dir = self.get_package_dir(name, requirements, url) p = PlatformFactory.newPlatform(pkg_dir) @@ -108,8 +108,8 @@ class PlatformManager(BasePkgManager): if isdir(package): pkg_dir = package else: - name, requirements, url = self.parse_pkg_input(package, - requirements) + name, requirements, url = self.parse_pkg_input( + package, requirements) pkg_dir = self.get_package_dir(name, requirements, url) p = PlatformFactory.newPlatform(pkg_dir) @@ -207,8 +207,8 @@ class PlatformFactory(object): else: if not requirements and "@" in name: name, requirements = name.rsplit("@", 1) - platform_dir = PlatformManager().get_package_dir(name, - requirements) + platform_dir = PlatformManager().get_package_dir( + name, requirements) if not platform_dir: raise exception.UnknownPlatform(name if not requirements else @@ -358,7 +358,8 @@ class PlatformRunMixin(object): util.get_pythonexe_path(), join(get_core_package_dir("tool-scons"), "script", "scons"), "-Q", "-j %d" % self.get_job_nums(), "--warn=no-no-parallel-support", - "-f", join(util.get_source_dir(), "builder", "main.py") + "-f", + join(util.get_source_dir(), "builder", "main.py") ] cmd.append("PIOVERBOSE=%d" % (1 if self.verbose else 0)) cmd += targets @@ -579,8 +580,10 @@ class PlatformBase( # pylint: disable=too-many-public-methods if not isdir(libcore_dir): continue storages.append({ - "name": "%s-core-%s" % (opts['package'], item), - "path": libcore_dir + "name": + "%s-core-%s" % (opts['package'], item), + "path": + libcore_dir }) return storages diff --git a/platformio/telemetry.py b/platformio/telemetry.py index 3a2b4aad..bcf39fbe 100644 --- a/platformio/telemetry.py +++ b/platformio/telemetry.py @@ -255,8 +255,9 @@ def measure_ci(): "label": getenv("APPVEYOR_REPO_NAME") }, "CIRCLECI": { - "label": "%s/%s" % (getenv("CIRCLE_PROJECT_USERNAME"), - getenv("CIRCLE_PROJECT_REPONAME")) + "label": + "%s/%s" % (getenv("CIRCLE_PROJECT_USERNAME"), + getenv("CIRCLE_PROJECT_REPONAME")) }, "TRAVIS": { "label": getenv("TRAVIS_REPO_SLUG") diff --git a/platformio/util.py b/platformio/util.py index 5b3d2302..df5d6c94 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -174,8 +174,8 @@ def load_json(file_path): with open(file_path, "r") as f: return json.load(f) except ValueError: - raise exception.PlatformioException("Could not load broken JSON: %s" % - file_path) + raise exception.PlatformioException( + "Could not load broken JSON: %s" % file_path) def get_systype(): @@ -282,8 +282,8 @@ def get_projectsrc_dir(): def get_projecttest_dir(): - return get_project_optional_dir("test_dir", - join(get_project_dir(), "test")) + return get_project_optional_dir("test_dir", join(get_project_dir(), + "test")) def get_projectboards_dir(): @@ -311,8 +311,8 @@ URL=http://docs.platformio.org/page/projectconf.html#envs-dir def get_projectdata_dir(): - return get_project_optional_dir("data_dir", - join(get_project_dir(), "data")) + return get_project_optional_dir("data_dir", join(get_project_dir(), + "data")) def load_project_config(path=None): @@ -495,8 +495,8 @@ def _get_api_result( else: raise exception.APIRequestError(e) except ValueError: - raise exception.APIRequestError("Invalid response: %s" % - r.text.encode("utf-8")) + raise exception.APIRequestError( + "Invalid response: %s" % r.text.encode("utf-8")) finally: if r: r.close() @@ -543,8 +543,8 @@ def internet_on(timeout=3): socket.setdefaulttimeout(timeout) for host in ("dl.bintray.com", "dl.platformio.org"): try: - socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect( - (host, 80)) + socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, + 80)) return True except: # pylint: disable=bare-except pass diff --git a/platformio/vcsclient.py b/platformio/vcsclient.py index e79da215..3ef64fe1 100644 --- a/platformio/vcsclient.py +++ b/platformio/vcsclient.py @@ -37,8 +37,8 @@ class VCSClientFactory(object): if "#" in remote_url: remote_url, tag = remote_url.rsplit("#", 1) if not type_: - raise PlatformioException("VCS: Unknown repository type %s" % - remote_url) + raise PlatformioException( + "VCS: Unknown repository type %s" % remote_url) obj = getattr(modules[__name__], "%sClient" % type_.title())( src_dir, remote_url, tag, silent) assert isinstance(obj, VCSClientBase) @@ -103,8 +103,8 @@ class VCSClientBase(object): if result['returncode'] == 0: return result['out'].strip() raise PlatformioException( - "VCS: Could not receive an output from `%s` command (%s)" % ( - args, result)) + "VCS: Could not receive an output from `%s` command (%s)" % + (args, result)) class GitClient(VCSClientBase):