diff mbox

pwclient: Don't display header for people who have no patches

Message ID 1404984239-10417-1-git-send-email-mpe@ellerman.id.au
State Accepted
Headers show

Commit Message

Michael Ellerman July 10, 2014, 9:23 a.m. UTC
When searching for patches by a person, currently pwclient prints the
header even for people who have no patches. This makes the output noiser
than it needs to be, eg:

  $ pwclient list -w foo
  Patches submitted by Ley Foon Tan <lftan@altera.com>:
  ID      State        Name
  --      -----        ----
  Patches submitted by  <ben@bigfootnetworks.com>:
  ID      State        Name
  --      -----        ----
  Patches submitted by James Y Knight <foom@fuhm.net>:
  ID      State        Name
  --      -----        ----
  Patches submitted by Steinar H. Gunderson <sgunderson@bigfoot.com>:
  ID      State        Name
  --      -----        ----
  Patches submitted by Lars-Peter Clausen <lars@metafoo.de>:
  ID      State        Name
  --      -----        ----
  Patches submitted by ainiaa2k9VG ainiaa5f8VG <camisetasfootballs@gmail.com>:
  ID      State        Name
  --      -----        ----

This commit changes the logic to only display the header info if there
are patches to display. It also tracks if there were any patches found
at all, if not it prints:

  $ pwclient list -w foo
  Note: No patches found for anyone matching *foo*

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 apps/patchwork/bin/pwclient | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Comments

Yann E. MORIN July 11, 2014, 4:32 p.m. UTC | #1
Michael, All,

On 2014-07-10 19:23 +1000, Michael Ellerman spake thusly:
> When searching for patches by a person, currently pwclient prints the
> header even for people who have no patches. This makes the output noiser
> than it needs to be, eg:
> 
>   $ pwclient list -w foo
>   Patches submitted by Ley Foon Tan <lftan@altera.com>:
>   ID      State        Name
>   --      -----        ----
>   Patches submitted by  <ben@bigfootnetworks.com>:
>   ID      State        Name
>   --      -----        ----
>   Patches submitted by James Y Knight <foom@fuhm.net>:
>   ID      State        Name
>   --      -----        ----
>   Patches submitted by Steinar H. Gunderson <sgunderson@bigfoot.com>:
>   ID      State        Name
>   --      -----        ----
>   Patches submitted by Lars-Peter Clausen <lars@metafoo.de>:
>   ID      State        Name
>   --      -----        ----
>   Patches submitted by ainiaa2k9VG ainiaa5f8VG <camisetasfootballs@gmail.com>:
>   ID      State        Name
>   --      -----        ----
> 
> This commit changes the logic to only display the header info if there
> are patches to display. It also tracks if there were any patches found
> at all, if not it prints:
> 
>   $ pwclient list -w foo
>   Note: No patches found for anyone matching *foo*
> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>

Regards,
Yann E. MORIN.

> ---
>  apps/patchwork/bin/pwclient | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/apps/patchwork/bin/pwclient b/apps/patchwork/bin/pwclient
> index dfbea3086275..5aa232378b74 100755
> --- a/apps/patchwork/bin/pwclient
> +++ b/apps/patchwork/bin/pwclient
> @@ -180,15 +180,24 @@ def action_list(rpc, filter, submitter_str, delegate_str):
>              sys.stderr.write("Note: Nobody found matching *%s*\n" % \
>                               submitter_str)
>          else:
> +            found = False
>              for id in ids:
> +                f = filter
> +                f.add("submitter_id", id)
> +                patches = rpc.patch_list(f.d)
> +                if len(patches) == 0:
> +                    continue
> +
> +                found = True
>                  person = rpc.person_get(id)
>                  print "Patches submitted by %s <%s>:" % \
>                          (unicode(person['name']).encode("utf-8"), \
>                           unicode(person['email']).encode("utf-8"))
> -                f = filter
> -                f.add("submitter_id", id)
> -                patches = rpc.patch_list(f.d)
>                  list_patches(patches)
> +
> +            if not found:
> +                sys.stderr.write("Note: No patches found for anyone matching *%s*\n" % \
> +                                 submitter_str)
>          return
>  
>      if delegate_str != "":
> -- 
> 1.9.1
> 
> _______________________________________________
> Patchwork mailing list
> Patchwork@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/patchwork
diff mbox

Patch

diff --git a/apps/patchwork/bin/pwclient b/apps/patchwork/bin/pwclient
index dfbea3086275..5aa232378b74 100755
--- a/apps/patchwork/bin/pwclient
+++ b/apps/patchwork/bin/pwclient
@@ -180,15 +180,24 @@  def action_list(rpc, filter, submitter_str, delegate_str):
             sys.stderr.write("Note: Nobody found matching *%s*\n" % \
                              submitter_str)
         else:
+            found = False
             for id in ids:
+                f = filter
+                f.add("submitter_id", id)
+                patches = rpc.patch_list(f.d)
+                if len(patches) == 0:
+                    continue
+
+                found = True
                 person = rpc.person_get(id)
                 print "Patches submitted by %s <%s>:" % \
                         (unicode(person['name']).encode("utf-8"), \
                          unicode(person['email']).encode("utf-8"))
-                f = filter
-                f.add("submitter_id", id)
-                patches = rpc.patch_list(f.d)
                 list_patches(patches)
+
+            if not found:
+                sys.stderr.write("Note: No patches found for anyone matching *%s*\n" % \
+                                 submitter_str)
         return
 
     if delegate_str != "":