diff mbox series

[08/14] diffconfig: fix code style

Message ID 1516581882-30582-9-git-send-email-ricardo.martincoski@gmail.com
State Superseded
Headers show
Series fix Python code style | expand

Commit Message

Ricardo Martincoski Jan. 22, 2018, 12:44 a.m. UTC
Fix these warnings:
E225 missing whitespace around operator
E231 missing whitespace after ','
E302 expected 2 blank lines, found 1
E305 expected 2 blank lines after class or function definition, found 1
E401 multiple imports on one line

Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
Cc: Marcus Folkesson <marcus.folkesson@gmail.com>
---
 utils/diffconfig | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

Comments

Thomas Petazzoni Jan. 29, 2018, 10:11 p.m. UTC | #1
Hello,

On Sun, 21 Jan 2018 22:44:36 -0200, Ricardo Martincoski wrote:
> Fix these warnings:
> E225 missing whitespace around operator
> E231 missing whitespace after ','
> E302 expected 2 blank lines, found 1
> E305 expected 2 blank lines after class or function definition, found 1
> E401 multiple imports on one line
> 
> Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
> Cc: Marcus Folkesson <marcus.folkesson@gmail.com>

I haven't applied this one, because I don't really like the fact that
we're further tweaking a script that comes from the kernel sources. On
the other hand, we have already tweaked it for our purposes.

What do others think? Should we stay as close to the original upstream
version as possible? Or because we have anyway already tweaked it, we
don't really care and can now do whatever changes we believe are useful?

Best regards,

Thomas
Marcus Folkesson Jan. 30, 2018, 8:25 p.m. UTC | #2
Hi,

On Mon, Jan 29, 2018 at 11:11:52PM +0100, Thomas Petazzoni wrote:
> Hello,
> 
> On Sun, 21 Jan 2018 22:44:36 -0200, Ricardo Martincoski wrote:
> > Fix these warnings:
> > E225 missing whitespace around operator
> > E231 missing whitespace after ','
> > E302 expected 2 blank lines, found 1
> > E305 expected 2 blank lines after class or function definition, found 1
> > E401 multiple imports on one line
> > 
> > Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
> > Cc: Marcus Folkesson <marcus.folkesson@gmail.com>
> 
> I haven't applied this one, because I don't really like the fact that
> we're further tweaking a script that comes from the kernel sources. On
> the other hand, we have already tweaked it for our purposes.
> 
> What do others think? Should we stay as close to the original upstream
> version as possible? Or because we have anyway already tweaked it, we
> don't really care and can now do whatever changes we believe are useful?

Well, I will try to keep the script reasonably synchronized between the
buildroot and kernel repo, and these type of patches does not really
help with that.

However, these scripts does not change that much, so I guess it does not
really matters.

> 
> Best regards,
> 
> Thomas
> -- 
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com


Best regards
Marcus Folkesson
Ricardo Martincoski Feb. 13, 2018, 3:14 a.m. UTC | #3
Hello,

On Tue, Jan 30, 2018 at 06:25 PM, Marcus Folkesson wrote:

> On Mon, Jan 29, 2018 at 11:11:52PM +0100, Thomas Petazzoni wrote:
[snip]
>> I haven't applied this one, because I don't really like the fact that
>> we're further tweaking a script that comes from the kernel sources. On
>> the other hand, we have already tweaked it for our purposes.
>>
>> What do others think? Should we stay as close to the original upstream
>> version as possible? Or because we have anyway already tweaked it, we
>> don't really care and can now do whatever changes we believe are useful?

I am happy either way.
If no one argues against, I will make flake8 ignore the file.

> Well, I will try to keep the script reasonably synchronized between the
> buildroot and kernel repo, and these type of patches does not really
> help with that.

Ignoring the file can be accomplished by 2 ways:

Adding this line to utils/diffconfig
# flake8: noqa

Adding this line to .flake8
exclude=utils/diffconfig

It looks to me the later is preferable. This way a script that don't need any
tweak can be a raw copy from the original.

Regards,
Ricardo
Thomas Petazzoni Feb. 13, 2018, 7:49 a.m. UTC | #4
Hello,

On Tue, 13 Feb 2018 01:14:40 -0200, Ricardo Martincoski wrote:

> Adding this line to .flake8
> exclude=utils/diffconfig
> 
> It looks to me the later is preferable. This way a script that don't need any
> tweak can be a raw copy from the original.

Agreed, the latter seems preferable to me.

Thanks!

Thomas
Marcus Folkesson Feb. 13, 2018, 8:44 a.m. UTC | #5
Hello,

On Tue, Feb 13, 2018 at 08:49:30AM +0100, Thomas Petazzoni wrote:
> Hello,
> 
> On Tue, 13 Feb 2018 01:14:40 -0200, Ricardo Martincoski wrote:
> 
> > Adding this line to .flake8
> > exclude=utils/diffconfig
> > 
> > It looks to me the later is preferable. This way a script that don't need any
> > tweak can be a raw copy from the original.
> 
> Agreed, the latter seems preferable to me.

Yes, please do that.

Could you please add utils/config as well?

> 
> Thanks!
> 
> Thomas
> -- 
> Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
> Embedded Linux and Kernel engineering
> http://bootlin.com


Thank you,
Marcus Folkesson
Ricardo Martincoski Feb. 14, 2018, 12:32 a.m. UTC | #6
Hello,

On Tue, Feb 13, 2018 at 06:44 AM, Marcus Folkesson wrote:
[snip]
> Could you please add utils/config as well?

It's not needed right now because only Python scripts will be checked in the
GitLab job with this series applied.

Regards,
Ricardo
diff mbox series

Patch

diff --git a/utils/diffconfig b/utils/diffconfig
index 5862a62..c8cd04c 100755
--- a/utils/diffconfig
+++ b/utils/diffconfig
@@ -8,7 +8,9 @@ 
 # Adapted to Buildroot 2017 by Marcus Folkesson
 #
 
-import sys, os
+import sys
+import os
+
 
 def usage():
     print("""Usage: diffconfig [-h] [-m] [<config1> <config2>]
@@ -40,6 +42,7 @@  Example usage:
 """)
     sys.exit(0)
 
+
 # returns a dictionary of name/value pairs for config items in the file
 def readconfig(config_file):
     d = {}
@@ -52,23 +55,25 @@  def readconfig(config_file):
             d[line[6:-11]] = "n"
     return d
 
+
 def print_config(op, config, value, new_value):
     global merge_style
 
     if merge_style:
         if new_value:
-            if new_value=="n":
+            if new_value == "n":
                 print("# BR2_%s is not set" % config)
             else:
                 print("BR2_%s=%s" % (config, new_value))
     else:
-        if op=="-":
+        if op == "-":
             print("-%s %s" % (config, value))
-        elif op=="+":
+        elif op == "+":
             print("+%s %s" % (config, new_value))
         else:
             print(" %s %s -> %s" % (config, value, new_value))
 
+
 def main():
     global merge_style
 
@@ -82,15 +87,15 @@  def main():
         sys.argv.remove("-m")
 
     argc = len(sys.argv)
-    if not (argc==1 or argc == 3):
+    if not (argc == 1 or argc == 3):
         print("Error: incorrect number of arguments or unrecognized option")
         usage()
 
     if argc == 1:
         # if no filenames given, assume .config and .config.old
-        build_dir=""
+        build_dir = ""
         if "KBUILD_OUTPUT" in os.environ:
-            build_dir = os.environ["KBUILD_OUTPUT"]+"/"
+            build_dir = os.environ["KBUILD_OUTPUT"] + "/"
         configa_filename = build_dir + ".config.old"
         configb_filename = build_dir + ".config"
     else:
@@ -102,7 +107,7 @@  def main():
         b = readconfig(open(configb_filename))
     except (IOError):
         e = sys.exc_info()[1]
-        print("I/O error[%s]: %s\n" % (e.args[0],e.args[1]))
+        print("I/O error[%s]: %s\n" % (e.args[0], e.args[1]))
         usage()
 
     # print items in a but not b (accumulate, sort and print)
@@ -133,4 +138,5 @@  def main():
     for config in new:
         print_config("+", config, None, b[config])
 
+
 main()