forked from platformio/platformio-core
Apply formatting
This commit is contained in:
@ -48,11 +48,13 @@ def team_list_cmd(orgname, json_output):
|
|||||||
table_data.append(
|
table_data.append(
|
||||||
(
|
(
|
||||||
"Members:",
|
"Members:",
|
||||||
", ".join(
|
(
|
||||||
(member.get("username") for member in team.get("members"))
|
", ".join(
|
||||||
)
|
(member.get("username") for member in team.get("members"))
|
||||||
if team.get("members")
|
)
|
||||||
else "-",
|
if team.get("members")
|
||||||
|
else "-"
|
||||||
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
click.echo(tabulate(table_data, tablefmt="plain"))
|
click.echo(tabulate(table_data, tablefmt="plain"))
|
||||||
|
@ -75,9 +75,11 @@ def LoadPioPlatform(env):
|
|||||||
continue
|
continue
|
||||||
env.PrependENVPath(
|
env.PrependENVPath(
|
||||||
"PATH",
|
"PATH",
|
||||||
os.path.join(pkg.path, "bin")
|
(
|
||||||
if os.path.isdir(os.path.join(pkg.path, "bin"))
|
os.path.join(pkg.path, "bin")
|
||||||
else pkg.path,
|
if os.path.isdir(os.path.join(pkg.path, "bin"))
|
||||||
|
else pkg.path
|
||||||
|
),
|
||||||
)
|
)
|
||||||
if (
|
if (
|
||||||
not IS_WINDOWS
|
not IS_WINDOWS
|
||||||
|
@ -122,9 +122,11 @@ def cli(
|
|||||||
silent=silent,
|
silent=silent,
|
||||||
src_filters=env_src_filters,
|
src_filters=env_src_filters,
|
||||||
flags=flags or env_options.get("check_flags"),
|
flags=flags or env_options.get("check_flags"),
|
||||||
severity=[DefectItem.SEVERITY_LABELS[DefectItem.SEVERITY_HIGH]]
|
severity=(
|
||||||
if silent
|
[DefectItem.SEVERITY_LABELS[DefectItem.SEVERITY_HIGH]]
|
||||||
else severity or config.get("env:" + envname, "check_severity"),
|
if silent
|
||||||
|
else severity or config.get("env:" + envname, "check_severity")
|
||||||
|
),
|
||||||
skip_packages=skip_packages or env_options.get("check_skip_packages"),
|
skip_packages=skip_packages or env_options.get("check_skip_packages"),
|
||||||
platform_packages=env_options.get("platform_packages"),
|
platform_packages=env_options.get("platform_packages"),
|
||||||
)
|
)
|
||||||
@ -142,9 +144,11 @@ def cli(
|
|||||||
|
|
||||||
result = {"env": envname, "tool": tool, "duration": time()}
|
result = {"env": envname, "tool": tool, "duration": time()}
|
||||||
rc = ct.check(
|
rc = ct.check(
|
||||||
on_defect_callback=None
|
on_defect_callback=(
|
||||||
if (json_output or verbose)
|
None
|
||||||
else lambda defect: click.echo(repr(defect))
|
if (json_output or verbose)
|
||||||
|
else lambda defect: click.echo(repr(defect))
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result["defects"] = ct.get_defects()
|
result["defects"] = ct.get_defects()
|
||||||
|
@ -194,9 +194,11 @@ class DebugConfigBase: # pylint: disable=too-many-instance-attributes
|
|||||||
cwd=server_package_dir if server_package else None,
|
cwd=server_package_dir if server_package else None,
|
||||||
executable=result.get("executable"),
|
executable=result.get("executable"),
|
||||||
arguments=[
|
arguments=[
|
||||||
a.replace("$PACKAGE_DIR", server_package_dir)
|
(
|
||||||
if server_package_dir
|
a.replace("$PACKAGE_DIR", server_package_dir)
|
||||||
else a
|
if server_package_dir
|
||||||
|
else a
|
||||||
|
)
|
||||||
for a in result.get("arguments", [])
|
for a in result.get("arguments", [])
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -144,9 +144,9 @@ def list_mdns_services():
|
|||||||
if service.properties:
|
if service.properties:
|
||||||
try:
|
try:
|
||||||
properties = {
|
properties = {
|
||||||
k.decode("utf8"): v.decode("utf8")
|
k.decode("utf8"): (
|
||||||
if isinstance(v, bytes)
|
v.decode("utf8") if isinstance(v, bytes) else v
|
||||||
else v
|
)
|
||||||
for k, v in service.properties.items()
|
for k, v in service.properties.items()
|
||||||
}
|
}
|
||||||
json.dumps(properties)
|
json.dumps(properties)
|
||||||
|
@ -125,9 +125,11 @@ def device_monitor_cmd(**options):
|
|||||||
options = apply_project_monitor_options(options, project_options)
|
options = apply_project_monitor_options(options, project_options)
|
||||||
register_filters(platform=platform, options=options)
|
register_filters(platform=platform, options=options)
|
||||||
options["port"] = SerialPortFinder(
|
options["port"] = SerialPortFinder(
|
||||||
board_config=platform.board_config(project_options.get("board"))
|
board_config=(
|
||||||
if platform and project_options.get("board")
|
platform.board_config(project_options.get("board"))
|
||||||
else None,
|
if platform and project_options.get("board")
|
||||||
|
else None
|
||||||
|
),
|
||||||
upload_protocol=project_options.get("upload_protocol"),
|
upload_protocol=project_options.get("upload_protocol"),
|
||||||
ensure_ready=True,
|
ensure_ready=True,
|
||||||
).find(initial_port=options["port"])
|
).find(initial_port=options["port"])
|
||||||
|
@ -372,15 +372,19 @@ class ProjectRPC(BaseRPCHandler):
|
|||||||
|
|
||||||
return dict(
|
return dict(
|
||||||
platform=dict(
|
platform=dict(
|
||||||
ownername=platform_pkg.metadata.spec.owner
|
ownername=(
|
||||||
if platform_pkg.metadata.spec
|
platform_pkg.metadata.spec.owner
|
||||||
else None,
|
if platform_pkg.metadata.spec
|
||||||
|
else None
|
||||||
|
),
|
||||||
name=platform.name,
|
name=platform.name,
|
||||||
title=platform.title,
|
title=platform.title,
|
||||||
version=str(platform_pkg.metadata.version),
|
version=str(platform_pkg.metadata.version),
|
||||||
),
|
),
|
||||||
board=platform.board_config(board_id).get_brief_data()
|
board=(
|
||||||
if board_id
|
platform.board_config(board_id).get_brief_data()
|
||||||
else None,
|
if board_id
|
||||||
|
else None
|
||||||
|
),
|
||||||
frameworks=frameworks or None,
|
frameworks=frameworks or None,
|
||||||
)
|
)
|
||||||
|
@ -63,9 +63,11 @@ class HTTPSession(requests.Session):
|
|||||||
kwargs["timeout"] = __default_requests_timeout__
|
kwargs["timeout"] = __default_requests_timeout__
|
||||||
return super().request(
|
return super().request(
|
||||||
method,
|
method,
|
||||||
url
|
(
|
||||||
if url.startswith("http") or not self._x_base_url
|
url
|
||||||
else urljoin(self._x_base_url, url),
|
if url.startswith("http") or not self._x_base_url
|
||||||
|
else urljoin(self._x_base_url, url)
|
||||||
|
),
|
||||||
*args,
|
*args,
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
@ -222,9 +222,11 @@ def _install_project_env_libraries(project_env, options):
|
|||||||
|
|
||||||
env_lm = LibraryPackageManager(
|
env_lm = LibraryPackageManager(
|
||||||
os.path.join(config.get("platformio", "libdeps_dir"), project_env),
|
os.path.join(config.get("platformio", "libdeps_dir"), project_env),
|
||||||
compatibility=PackageCompatibility(**compatibility_qualifiers)
|
compatibility=(
|
||||||
if compatibility_qualifiers
|
PackageCompatibility(**compatibility_qualifiers)
|
||||||
else None,
|
if compatibility_qualifiers
|
||||||
|
else None
|
||||||
|
),
|
||||||
)
|
)
|
||||||
private_lm = LibraryPackageManager(
|
private_lm = LibraryPackageManager(
|
||||||
os.path.join(config.get("platformio", "lib_dir"))
|
os.path.join(config.get("platformio", "lib_dir"))
|
||||||
|
@ -65,10 +65,12 @@ def print_search_item(item):
|
|||||||
click.echo(
|
click.echo(
|
||||||
"%s • %s • Published on %s"
|
"%s • %s • Published on %s"
|
||||||
% (
|
% (
|
||||||
item["type"].capitalize()
|
(
|
||||||
if item["tier"] == "community"
|
item["type"].capitalize()
|
||||||
else click.style(
|
if item["tier"] == "community"
|
||||||
("%s %s" % (item["tier"], item["type"])).title(), bold=True
|
else click.style(
|
||||||
|
("%s %s" % (item["tier"], item["type"])).title(), bold=True
|
||||||
|
)
|
||||||
),
|
),
|
||||||
item["version"]["name"],
|
item["version"]["name"],
|
||||||
util.parse_datetime(item["version"]["released_at"]).strftime("%c"),
|
util.parse_datetime(item["version"]["released_at"]).strftime("%c"),
|
||||||
|
@ -98,9 +98,9 @@ class PackageManagerInstallMixin:
|
|||||||
else:
|
else:
|
||||||
pkg = self.install_from_registry(
|
pkg = self.install_from_registry(
|
||||||
spec,
|
spec,
|
||||||
search_qualifiers=compatibility.to_search_qualifiers()
|
search_qualifiers=(
|
||||||
if compatibility
|
compatibility.to_search_qualifiers() if compatibility else None
|
||||||
else None,
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
if not pkg or not pkg.metadata:
|
if not pkg or not pkg.metadata:
|
||||||
|
@ -294,9 +294,11 @@ class BaseManifestParser:
|
|||||||
if not matched_files:
|
if not matched_files:
|
||||||
continue
|
continue
|
||||||
result[root] = dict(
|
result[root] = dict(
|
||||||
name="Examples"
|
name=(
|
||||||
if root == examples_dir
|
"Examples"
|
||||||
else os.path.relpath(root, examples_dir),
|
if root == examples_dir
|
||||||
|
else os.path.relpath(root, examples_dir)
|
||||||
|
),
|
||||||
base=os.path.relpath(root, package_dir),
|
base=os.path.relpath(root, package_dir),
|
||||||
files=matched_files,
|
files=matched_files,
|
||||||
)
|
)
|
||||||
|
@ -485,9 +485,11 @@ class PackageItem:
|
|||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
conds = [
|
conds = [
|
||||||
os.path.realpath(self.path) == os.path.realpath(other.path)
|
(
|
||||||
if self.path and other.path
|
os.path.realpath(self.path) == os.path.realpath(other.path)
|
||||||
else self.path == other.path,
|
if self.path and other.path
|
||||||
|
else self.path == other.path
|
||||||
|
),
|
||||||
self.metadata == other.metadata,
|
self.metadata == other.metadata,
|
||||||
]
|
]
|
||||||
return all(conds)
|
return all(conds)
|
||||||
|
@ -116,9 +116,9 @@ class PlatformRunMixin:
|
|||||||
args,
|
args,
|
||||||
stdout=proc.BuildAsyncPipe(
|
stdout=proc.BuildAsyncPipe(
|
||||||
line_callback=self._on_stdout_line,
|
line_callback=self._on_stdout_line,
|
||||||
data_callback=lambda data: None
|
data_callback=lambda data: (
|
||||||
if self.silent
|
None if self.silent else _write_and_flush(sys.stdout, data)
|
||||||
else _write_and_flush(sys.stdout, data),
|
),
|
||||||
),
|
),
|
||||||
stderr=proc.BuildAsyncPipe(
|
stderr=proc.BuildAsyncPipe(
|
||||||
line_callback=self._on_stderr_line,
|
line_callback=self._on_stderr_line,
|
||||||
|
@ -82,9 +82,11 @@ def lint_configuration(json_output=False):
|
|||||||
(
|
(
|
||||||
click.style(error["type"], fg="red"),
|
click.style(error["type"], fg="red"),
|
||||||
error["message"],
|
error["message"],
|
||||||
error.get("source", "") + (f":{error.get('lineno')}")
|
(
|
||||||
if "lineno" in error
|
error.get("source", "") + (f":{error.get('lineno')}")
|
||||||
else "",
|
if "lineno" in error
|
||||||
|
else ""
|
||||||
|
),
|
||||||
)
|
)
|
||||||
for error in errors
|
for error in errors
|
||||||
],
|
],
|
||||||
|
@ -91,9 +91,11 @@ class ProjectGenerator:
|
|||||||
"default_debug_env_name": get_default_debug_env(self.config),
|
"default_debug_env_name": get_default_debug_env(self.config),
|
||||||
"env_name": self.env_name,
|
"env_name": self.env_name,
|
||||||
"user_home_dir": os.path.abspath(fs.expanduser("~")),
|
"user_home_dir": os.path.abspath(fs.expanduser("~")),
|
||||||
"platformio_path": sys.argv[0]
|
"platformio_path": (
|
||||||
if os.path.isfile(sys.argv[0])
|
sys.argv[0]
|
||||||
else where_is_program("platformio"),
|
if os.path.isfile(sys.argv[0])
|
||||||
|
else where_is_program("platformio")
|
||||||
|
),
|
||||||
"env_path": os.getenv("PATH"),
|
"env_path": os.getenv("PATH"),
|
||||||
"env_pathsep": os.pathsep,
|
"env_pathsep": os.pathsep,
|
||||||
}
|
}
|
||||||
|
@ -41,9 +41,11 @@ def access_list_cmd(owner, urn_type, json_output): # pylint: disable=unused-arg
|
|||||||
table_data.append(
|
table_data.append(
|
||||||
(
|
(
|
||||||
"Access:",
|
"Access:",
|
||||||
click.style("Private", fg="red")
|
(
|
||||||
if resource.get("private", False)
|
click.style("Private", fg="red")
|
||||||
else "Public",
|
if resource.get("private", False)
|
||||||
|
else "Public"
|
||||||
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
table_data.append(
|
table_data.append(
|
||||||
|
@ -54,9 +54,11 @@ class RegistryFileMirrorIterator:
|
|||||||
"head",
|
"head",
|
||||||
self._url_parts.path,
|
self._url_parts.path,
|
||||||
allow_redirects=False,
|
allow_redirects=False,
|
||||||
params=dict(bypass=",".join(self._visited_mirrors))
|
params=(
|
||||||
if self._visited_mirrors
|
dict(bypass=",".join(self._visited_mirrors))
|
||||||
else None,
|
if self._visited_mirrors
|
||||||
|
else None
|
||||||
|
),
|
||||||
x_with_authorization=RegistryClient.allowed_private_packages(),
|
x_with_authorization=RegistryClient.allowed_private_packages(),
|
||||||
)
|
)
|
||||||
stop_conditions = [
|
stop_conditions = [
|
||||||
|
@ -123,9 +123,11 @@ class DeviceMonitorClient( # pylint: disable=too-many-instance-attributes
|
|||||||
index=i + 1,
|
index=i + 1,
|
||||||
host=device[0] + ":" if len(result) > 1 else "",
|
host=device[0] + ":" if len(result) > 1 else "",
|
||||||
port=device[1]["port"],
|
port=device[1]["port"],
|
||||||
description=device[1]["description"]
|
description=(
|
||||||
if device[1]["description"] != "n/a"
|
device[1]["description"]
|
||||||
else "",
|
if device[1]["description"] != "n/a"
|
||||||
|
else ""
|
||||||
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
device_index = click.prompt(
|
device_index = click.prompt(
|
||||||
|
@ -62,11 +62,13 @@ class JsonTestReport(TestReportBase):
|
|||||||
test_dir=test_suite.test_dir,
|
test_dir=test_suite.test_dir,
|
||||||
status=test_suite.status.name,
|
status=test_suite.status.name,
|
||||||
duration=test_suite.duration,
|
duration=test_suite.duration,
|
||||||
timestamp=datetime.datetime.fromtimestamp(test_suite.timestamp).strftime(
|
timestamp=(
|
||||||
"%Y-%m-%dT%H:%M:%S"
|
datetime.datetime.fromtimestamp(test_suite.timestamp).strftime(
|
||||||
)
|
"%Y-%m-%dT%H:%M:%S"
|
||||||
if test_suite.timestamp
|
)
|
||||||
else None,
|
if test_suite.timestamp
|
||||||
|
else None
|
||||||
|
),
|
||||||
testcase_nums=len(test_suite.cases),
|
testcase_nums=len(test_suite.cases),
|
||||||
error_nums=test_suite.get_status_nums(TestStatus.ERRORED),
|
error_nums=test_suite.get_status_nums(TestStatus.ERRORED),
|
||||||
failure_nums=test_suite.get_status_nums(TestStatus.FAILED),
|
failure_nums=test_suite.get_status_nums(TestStatus.FAILED),
|
||||||
|
Reference in New Issue
Block a user