[PATCH v2 3/3] pwclient: Allow using a submitter id to filter

Doug Anderson dianders at chromium.org
Tue Dec 4 11:08:19 EST 2012

Now that we can know what the submitter id is for a given email
address (because of the info command), allow it to be used to list

This can be used to work around problems with patchwork servers that
have problems with users that have no real name.

Signed-off-by: Doug Anderson <dianders at chromium.org>
Changes in v2: None

 apps/patchwork/bin/pwclient |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/apps/patchwork/bin/pwclient b/apps/patchwork/bin/pwclient
index 27bfdb3..8cccd3c 100755
--- a/apps/patchwork/bin/pwclient
+++ b/apps/patchwork/bin/pwclient
@@ -160,7 +160,7 @@ def usage():
     sys.stderr.write("""\nFilter options for 'list' and 'search':
         -s <state>    : Filter by patch state (e.g., 'New', 'Accepted', etc.)
         -p <project>  : Filter by project name (see 'projects' for list)
-        -w <who>      : Filter by submitter (name, e-mail substring search)
+        -w <who>      : Filter by submitter (name, e-mail substring, or ID)
         -d <who>      : Filter by delegate (name, e-mail substring search)
         -n <max #>    : Restrict number of results
         -m <messageid>: Filter by Message-Id\n""")
@@ -190,10 +190,17 @@ def state_id_by_name(rpc, name):
     return 0
 def person_ids_by_name(rpc, name):
-    """Given a partial name or email address, return a list of the
-    person IDs that match."""
+    """Given a partial name, email address, or submitter ID, return a list
+    of the person IDs that match."""
     if len(name) == 0:
         return []
+    # If the ID is an int then assume it's a submitter ID.
+    try:
+        return [ int(name) ]
+    except ValueError:
+        pass
     people = rpc.person_list(name, 0)
     return map(lambda x: x['id'], people)

More information about the Patchwork mailing list