[Buildroot] [PATCH v3 02/12] support/scripts/pkg-stats: store patch files for the package

Titouan Christophe titouan.christophe at railnova.eu
Sun Feb 23 13:35:11 UTC 2020


Heiko,


On 2/22/20 9:57 AM, Heiko Thiery wrote:
> From: Heiko Thiery <heiko.thiery at kontron.com>
> 
> Signed-off-by: Heiko Thiery <heiko.thiery at kontron.com>
> Signed-off-by: Heiko Thiery <heiko.thiery at gmail.com>

Same as the previous patch, signed off with 2 different email addresses.

> ---
>   support/scripts/pkg-stats | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
> index 8cc78f2f66..4c963cef0f 100755
> --- a/support/scripts/pkg-stats
> +++ b/support/scripts/pkg-stats
> @@ -65,6 +65,7 @@ class Package:
>           self.has_license_files = False
>           self.has_hash = False
>           self.patch_count = 0
> +        self.patch_files = []
>           self.warnings = 0
>           self.current_version = None
>           self.url = None
> @@ -131,10 +132,10 @@ class Package:
>           """
>           Fills in the .patch_count field
>           """
> -        self.patch_count = 0
>           pkgdir = os.path.dirname(self.path)
>           for subdir, _, _ in os.walk(pkgdir):
> -            self.patch_count += len(fnmatch.filter(os.listdir(subdir), '*.patch'))
> +            self.patch_files = fnmatch.filter(os.listdir(subdir), '*.patch')
> +            self.patch_count = len(self.patch_files)

We can compute the patch_count only once after looping through all the 
files, no need to update it at each step.

Maybe we can also entirely remove this patch_count attribute from the 
Package class, and define it as a property:

class Package:
     # ...
     @property
     def patch_count(self):
         return len(self.patch_files)

>   
>       def set_current_version(self):
>           """
> 


Best regards,

Titouan



More information about the buildroot mailing list