2023-10-13 13:29:36

by Hu Haowen

[permalink] [raw]
Subject: [PATCH] scripts/show_delta: add __main__ judgement before main code

When doing Python programming it is a nice convention to insert the if
statement `if __name__ == "__main__":` before any main code that does
actual functionalities to ensure the code will be executed only as a
script rather than as an imported module. Hence attach the missing
judgement to show_delta.

Signed-off-by: Hu Haowen <[email protected]>
---
scripts/show_delta | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/show_delta b/scripts/show_delta
index 28e67e178194..291ad65e3089 100755
--- a/scripts/show_delta
+++ b/scripts/show_delta
@@ -125,4 +125,5 @@ def main():
for line in lines:
print (convert_line(line, base_time),)

-main()
+if __name__ == "__main__":
+ main()
--
2.34.1


2023-10-13 20:28:16

by Nick Desaulniers

[permalink] [raw]
Subject: Re: [PATCH] scripts/show_delta: add __main__ judgement before main code

On Fri, Oct 13, 2023 at 6:29 AM Hu Haowen <[email protected]> wrote:
>
> When doing Python programming it is a nice convention to insert the if
> statement `if __name__ == "__main__":` before any main code that does
> actual functionalities to ensure the code will be executed only as a
> script rather than as an imported module. Hence attach the missing
> judgement to show_delta.
>
> Signed-off-by: Hu Haowen <[email protected]>

Thanks for the patch!
Reviewed-by: Nick Desaulniers <[email protected]>

> ---
> scripts/show_delta | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/show_delta b/scripts/show_delta
> index 28e67e178194..291ad65e3089 100755
> --- a/scripts/show_delta
> +++ b/scripts/show_delta
> @@ -125,4 +125,5 @@ def main():
> for line in lines:
> print (convert_line(line, base_time),)
>
> -main()
> +if __name__ == "__main__":
> + main()
> --
> 2.34.1
>


--
Thanks,
~Nick Desaulniers

2023-10-14 10:15:29

by Miguel Ojeda

[permalink] [raw]
Subject: Re: [PATCH] scripts/show_delta: add __main__ judgement before main code

On Fri, Oct 13, 2023 at 3:29 PM Hu Haowen <[email protected]> wrote:
>
> When doing Python programming it is a nice convention to insert the if
> statement `if __name__ == "__main__":` before any main code that does
> actual functionalities to ensure the code will be executed only as a
> script rather than as an imported module. Hence attach the missing
> judgement to show_delta.
>
> Signed-off-by: Hu Haowen <[email protected]>

I am not sure why I was Cc'd, but the patch looks fine :)

Reviewed-by: Miguel Ojeda <[email protected]>

Cheers,
Miguel

2023-10-14 17:28:51

by Hu Haowen

[permalink] [raw]
Subject: Re: [PATCH] scripts/show_delta: add __main__ judgement before main code


On 2023/10/14 18:15, Miguel Ojeda wrote:
> On Fri, Oct 13, 2023 at 3:29 PM Hu Haowen <[email protected]> wrote:
>> When doing Python programming it is a nice convention to insert the if
>> statement `if __name__ == "__main__":` before any main code that does
>> actual functionalities to ensure the code will be executed only as a
>> script rather than as an imported module. Hence attach the missing
>> judgement to show_delta.
>>
>> Signed-off-by: Hu Haowen <[email protected]>
> I am not sure why I was Cc'd, but the patch looks fine :)


Sorry for troubling you. I have just executed the get_maintainer script
to get the maintainer for the file I'm making the patch toward, with
the result that this file is not maintained by anyone. Consequently I
immediately ran again on the scripts directory, and obtained adequate
information on major commiters of scripts, adding them to the Cc list.

After all, it's nice of you to have ensured the quality of my patch. :)


> Reviewed-by: Miguel Ojeda <[email protected]>
>
> Cheers,
> Miguel
>