public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scripts/show_delta: reformat code
@ 2023-11-30 14:38 Hu Haowen
  2023-11-30 17:13 ` Miguel Ojeda
  0 siblings, 1 reply; 4+ messages in thread
From: Hu Haowen @ 2023-11-30 14:38 UTC (permalink / raw)
  To: gregkh, akpm
  Cc: Hu Haowen, masahiroy, ndesaulniers, n.schier, ojeda, linux-kernel

Correct some lines in irregular coding style to make them look more
harmonious and fit the common coding regulations in Python.

Signed-off-by: Hu Haowen <2023002089@link.tyut.edu.cn>
---
 scripts/show_delta | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/scripts/show_delta b/scripts/show_delta
index 291ad65e3089..f5e42780ee7b 100755
--- a/scripts/show_delta
+++ b/scripts/show_delta
@@ -13,7 +13,7 @@ import sys
 import string
 
 def usage():
-	print ("""usage: show_delta [<options>] <filename>
+	print("""usage: show_delta [<options>] <filename>
 
 This program parses the output from a set of printk message lines which
 have time data prefixed because the CONFIG_PRINTK_TIME option is set, or
@@ -46,7 +46,7 @@ def get_time(line):
 		raise ValueError
 
 	# split on closing bracket
-	(time_str, rest) = string.split(line[1:],']',1)
+	(time_str, rest) = string.split(line[1:], ']', 1)
 	time = string.atof(time_str)
 
 	#print "time=", time
@@ -82,7 +82,7 @@ def main():
 	filein = ""
 	for arg in sys.argv[1:]:
 		if arg=="-b":
-			base_str = sys.argv[sys.argv.index("-b")+1]
+			base_str = sys.argv[sys.argv.index("-b") + 1]
 		elif arg=="-h":
 			usage()
 		else:
@@ -111,19 +111,19 @@ def main():
 					(time, rest) = get_time(line)
 				except:
 					continue
-				if string.find(rest, base_str)==1:
+				if string.find(rest, base_str) == 1:
 					base_time = time
 					found = 1
 					# stop at first match
 					break
 			if not found:
-				print ('Couldn\'t find line matching base pattern "%s"' % base_str)
+				print('Couldn\'t find line matching base pattern "%s"' % base_str)
 				sys.exit(1)
 	else:
 		base_time = 0.0
 
 	for line in lines:
-		print (convert_line(line, base_time),)
+		print(convert_line(line, base_time),)
 
 if __name__ == "__main__":
 	main()
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] scripts/show_delta: reformat code
  2023-11-30 14:38 [PATCH] scripts/show_delta: reformat code Hu Haowen
@ 2023-11-30 17:13 ` Miguel Ojeda
  2023-12-01  4:56   ` Hu Haowen
  0 siblings, 1 reply; 4+ messages in thread
From: Miguel Ojeda @ 2023-11-30 17:13 UTC (permalink / raw)
  To: Hu Haowen
  Cc: gregkh, akpm, masahiroy, ndesaulniers, n.schier, ojeda,
	linux-kernel

On Thu, Nov 30, 2023 at 3:49 PM Hu Haowen <2023002089@link.tyut.edu.cn> wrote:
>
> -                               if string.find(rest, base_str)==1:
> +                               if string.find(rest, base_str) == 1:

If this is changed, shouldn't be others like:

>                 if arg=="-b":
>                 elif arg=="-h":

be changed too?

In other words, it seems this was done manually. Should we instead
introduce/use something like Black or Ruff if we are going to do this
sort of changes?

Thanks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scripts/show_delta: reformat code
  2023-11-30 17:13 ` Miguel Ojeda
@ 2023-12-01  4:56   ` Hu Haowen
  2023-12-01 12:10     ` Nicolas Schier
  0 siblings, 1 reply; 4+ messages in thread
From: Hu Haowen @ 2023-12-01  4:56 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: gregkh, akpm, masahiroy, ndesaulniers, n.schier, ojeda,
	linux-kernel


On 2023/12/1 01:13, Miguel Ojeda wrote:
> On Thu, Nov 30, 2023 at 3:49 PM Hu Haowen <2023002089@link.tyut.edu.cn> wrote:
>> -                               if string.find(rest, base_str)==1:
>> +                               if string.find(rest, base_str) == 1:
> If this is changed, shouldn't be others like:
>
>>                  if arg=="-b":
>>                  elif arg=="-h":
> be changed too?


Sorry, ignored by accident. I'll make up within the next patch version.


> In other words, it seems this was done manually. Should we instead
> introduce/use something like Black or Ruff if we are going to do this
> sort of changes?


I'm sorry but I'm not familiar with these two things. Are Black and Ruff
some kind of tools which help identify these code format issues? If so
it is better to introduce them to assist to accomplish the similar
series of work instead of only completing it manually with avoiding
omitted parts simultaneously.

Thanks,
Hu Haowen


> Thanks!
>
> Cheers,
> Miguel
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scripts/show_delta: reformat code
  2023-12-01  4:56   ` Hu Haowen
@ 2023-12-01 12:10     ` Nicolas Schier
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Schier @ 2023-12-01 12:10 UTC (permalink / raw)
  To: Hu Haowen
  Cc: Miguel Ojeda, gregkh, akpm, masahiroy, ndesaulniers, ojeda,
	linux-kernel

On Fri, Dec 01, 2023 at 12:56:14PM +0800, Hu Haowen wrote:
> 
> On 2023/12/1 01:13, Miguel Ojeda wrote:
> > On Thu, Nov 30, 2023 at 3:49 PM Hu Haowen <2023002089@link.tyut.edu.cn> wrote:
> > > -                               if string.find(rest, base_str)==1:
> > > +                               if string.find(rest, base_str) == 1:
> > If this is changed, shouldn't be others like:
> > 
> > >                  if arg=="-b":
> > >                  elif arg=="-h":
> > be changed too?
> 
> 
> Sorry, ignored by accident. I'll make up within the next patch version.
> 
> 
> > In other words, it seems this was done manually. Should we instead
> > introduce/use something like Black or Ruff if we are going to do this
> > sort of changes?
> 
> 
> I'm sorry but I'm not familiar with these two things. Are Black and Ruff
> some kind of tools which help identify these code format issues? If so
> it is better to introduce them to assist to accomplish the similar
> series of work instead of only completing it manually with avoiding
> omitted parts simultaneously.

yes, both are Python code formatters:

Black:
   Documentation: https://black.readthedocs.io/en/stable/
   Repology:      https://repology.org/project/black/

Ruff:
   Documentation: https://docs.astral.sh/ruff/formatter/
   Repology: https://repology.org/project/ruff-python-linter/

Kind regards,
Nicolas

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-01 12:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-30 14:38 [PATCH] scripts/show_delta: reformat code Hu Haowen
2023-11-30 17:13 ` Miguel Ojeda
2023-12-01  4:56   ` Hu Haowen
2023-12-01 12:10     ` Nicolas Schier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox