| Summary: | bitbake: Use a standard python code formatter | ||
|---|---|---|---|
| Product: | [Build System, Metadata & Runtime] BitBake | Reporter: | Randy MacLeod <randy.macleod> |
| Component: | bitbake | Assignee: | Richard Purdie <richard.purdie> |
| Status: | RESOLVED WONTFIX | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | Undecided | CC: | poky.bs.watcher, poky.watcher |
| Version: | 5.99 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | Multiple | ||
| Whiteboard: | |||
| OS type for building Yocto: | --- | Type of Regression: | --- |
| Verified: | Documentation change: | Yes (doc changes required) | |
|
Description
Randy MacLeod
2022-02-01 17:32:19 UTC
Running:
$ for i in `ls lib/bb/*py`; do echo $i; black $i; done
results in diffs below. bitbake works well without any manual changes and bitbake-selftest also completes without error.
Running:
$ for i in `ls lib/bb/*py`; do echo $i; black $i; done
results in:
$ git diff | diffstat
COW.py | 37 -
__init__.py | 71 +-
build.py | 401 +++++++++------
cache.py | 242 +++++----
cache_extra.py | 36 -
checksum.py | 12
codeparser.py | 84 ++-
command.py | 159 ++++--
cooker.py | 844 +++++++++++++++++++++++---------
cookerdata.py | 249 ++++++---
daemonize.py | 11
data.py | 192 +++++--
data_smart.py | 440 +++++++++--------
event.py | 246 +++++++--
exceptions.py | 40 -
main.py | 639 +++++++++++++++++-------
methodpool.py | 4
monitordisk.py | 116 +++-
msg.py | 131 +++--
namedtuple_with_abc.py | 66 +-
persist_data.py | 52 +-
process.py | 25
progress.py | 52 +-
providers.py | 153 ++++-
remotedata.py | 5
runqueue.py | 1242 ++++++++++++++++++++++++++++++++++++------------
siggen.py | 765 +++++++++++++++++++----------
taskdata.py | 208 ++++++--
tinfoil.py | 400 +++++++++------
29 files changed, 4788 insertions(+), 2134 deletions(-)
Here's an example of the changes made for a short diff: process.py:
---
$ git diff lib/bb/process.py | cat
diff --git a/lib/bb/process.py b/lib/bb/process.py
index af5d804a..3d9f2732 100644
--- a/lib/bb/process.py
+++ b/lib/bb/process.py
@@ -9,13 +9,15 @@ import errno
import select
import bb
-logger = logging.getLogger('BitBake.Process')
+logger = logging.getLogger("BitBake.Process")
+
def subprocess_setup():
# Python installs a SIGPIPE handler by default. This is usually not what
# non-Python subprocesses expect.
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
+
class CmdError(RuntimeError):
def __init__(self, command, msg=None):
self.command = command
@@ -29,15 +31,17 @@ class CmdError(RuntimeError):
msg = "Execution of '%s' failed" % cmd
if self.msg:
- msg += ': %s' % self.msg
+ msg += ": %s" % self.msg
return msg
+
class NotFoundError(CmdError):
def __str__(self):
return CmdError.__str__(self) + ": command not found"
+
class ExecutionError(CmdError):
- def __init__(self, command, exitcode, stdout = None, stderr = None):
+ def __init__(self, command, exitcode, stdout=None, stderr=None):
CmdError.__init__(self, command)
self.exitcode = exitcode
self.stdout = stdout
@@ -52,8 +56,13 @@ class ExecutionError(CmdError):
message += self.stdout
if message:
message = ":\n" + message
- return (CmdError.__str__(self) +
- " with exit code %s" % self.exitcode + message + (self.extra_message or ""))
+ return (
+ CmdError.__str__(self)
+ + " with exit code %s" % self.exitcode
+ + message
+ + (self.extra_message or "")
+ )
+
class Popen(subprocess.Popen):
defaults = {
@@ -70,6 +79,7 @@ class Popen(subprocess.Popen):
options.update(kwargs)
subprocess.Popen.__init__(self, *args, **options)
+
def _logged_communicate(pipe, log, input, extrafiles):
if pipe.stdin:
if input is not None:
@@ -106,7 +116,7 @@ def _logged_communicate(pipe, log, input, extrafiles):
stderrbuf = b""
try:
- r,w,e = select.select (rlist, [], [], 1)
+ r, w, e = select.select(rlist, [], [], 1)
except OSError as e:
if e.errno != errno.EINTR:
raise
@@ -151,7 +161,8 @@ def _logged_communicate(pipe, log, input, extrafiles):
pipe.stdout.close()
if pipe.stderr is not None:
pipe.stderr.close()
- return ''.join(outdata), ''.join(errdata)
+ return "".join(outdata), "".join(errdata)
+
def run(cmd, input=None, log=None, extrafiles=None, **options):
"""Convenience function to run a command and return its output, raising an
---
FYI, running on my laptop:
---
$ bitbake-selftest
......................................................................................................................................................................................................................................................................................................ssss.ssssssssssssssss.sssss..........................................................................................................................................
----------------------------------------------------------------------
Ran 459 tests in 957.812s
OK (skipped=25)
$ echo $?
0
---
We have an older code-base and we're happy with out existing formatting conventions. We can adapt the code-base as we update individual files. We don't want a big transition that will make tracing changes across the commit mess difficult. |