diff mbox series

[1/1] Check if two spaces between fields in hash file

Message ID qagxdWV55NSsOiPMpXTP3jHIEfqwaUmTL_EAlKzZD1EUoCg_dqyTA6GpJVG705r_Wavn8HP2hZEDvT5FbSBRTHBU1rKtIhb6WZejUcKSwSE=@protonmail.com
State New
Headers show
Series [1/1] Check if two spaces between fields in hash file | expand

Commit Message

Yair Ben-Avraham May 18, 2020, 7:39 a.m. UTC
Signed-off-by: Yair Ben Avraham <yairba@protonmail.com>
---
 utils/checkpackagelib/lib_hash.py | 5 +++++
 1 file changed, 5 insertions(+)

--
2.20.1

Comments

Heiko Thiery May 18, 2020, 11 a.m. UTC | #1
Hi Yair and all,

Am Mo., 18. Mai 2020 um 09:39 Uhr schrieb Yair Ben-Avraham <
yairba@protonmail.com>:

> Signed-off-by: Yair Ben Avraham <yairba@protonmail.com>
> ---
>  utils/checkpackagelib/lib_hash.py | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/utils/checkpackagelib/lib_hash.py
> b/utils/checkpackagelib/lib_hash.py
> index 3e381119a5..064d8cb37f 100644
> --- a/utils/checkpackagelib/lib_hash.py
> +++ b/utils/checkpackagelib/lib_hash.py
> @@ -27,6 +27,11 @@ class HashNumberOfFields(_CheckFunction):
>                      .format(self.filename, lineno, self.url_to_manual),
>                      text]
>
> +        if (2 != text.rpartition('  ')[0].count(' ') or
> +            2 != text.partition('  ')[-1].count(' ')):
> +            return ["{}:{} expected two spaces between fields"
> +                    .format(self.filename, lineno), text]
> +
>
>  class HashType(_CheckFunction):
>      len_of_hash = {"md5": 32, "sha1": 40, "sha224": 56, "sha256": 64,
>
>
There is already a similar patch available:
https://patchwork.ozlabs.org/project/buildroot/patch/20200205212211.29720-1-heiko.thiery@gmail.com/
diff mbox series

Patch

diff --git a/utils/checkpackagelib/lib_hash.py b/utils/checkpackagelib/lib_hash.py
index 3e381119a5..064d8cb37f 100644
--- a/utils/checkpackagelib/lib_hash.py
+++ b/utils/checkpackagelib/lib_hash.py
@@ -27,6 +27,11 @@  class HashNumberOfFields(_CheckFunction):
                     .format(self.filename, lineno, self.url_to_manual),
                     text]

+        if (2 != text.rpartition('  ')[0].count(' ') or
+            2 != text.partition('  ')[-1].count(' ')):
+            return ["{}:{} expected two spaces between fields"
+                    .format(self.filename, lineno), text]
+

 class HashType(_CheckFunction):
     len_of_hash = {"md5": 32, "sha1": 40, "sha224": 56, "sha256": 64,