[PATCH 3/3] pwclient: support 'archived' filtering and updating
Keller, Jacob E
jacob.e.keller at intel.com
Tue Nov 25 10:46:34 AEDT 2014
Regarding argparse: You can do it by making both args optional and then complaint if one isn't set afterwards.
I never found a better way to express complex arguments dependencies.
Regards
Jake
Sent from my Verizon Wireless 4G LTE smartphone
-------- Original message --------
From: Brian Norris
Date:11/22/2014 9:50 PM (GMT-08:00)
To: patchwork at lists.ozlabs.org
Subject: [PATCH 3/3] pwclient: support 'archived' filtering and updating
Examples:
# Mark patch as uperseded and archived
pwclient update -s Superseded -a yes <ID>
# List all archived patches
pwclient list -a yes
Notably, we still leave the '-s' option as required for 'pwclient
update'; so you can't *just* archive a patch without setting its state.
I couldn't quite figure out the right argparse usage to represent that
the user must include one or both of '-s' and '-a'.
And of course, the server must have an updated xmlrpc that supports the
'archived' field for list filtering (recently patched), otherwise you'll
just get an empty list.
Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
apps/patchwork/bin/pwclient | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/apps/patchwork/bin/pwclient b/apps/patchwork/bin/pwclient
index 70d4f8293272..0a477c26aa61 100755
--- a/apps/patchwork/bin/pwclient
+++ b/apps/patchwork/bin/pwclient
@@ -274,7 +274,7 @@ def action_apply(rpc, patch_id, apply_cmd=None):
sys.stderr.write("Error: No patch content found\n")
sys.exit(1)
-def action_update_patch(rpc, patch_id, state = None, commit = None):
+def action_update_patch(rpc, patch_id, state = None, archived = None, commit = None):
patch = rpc.patch_get(patch_id)
if patch == {}:
sys.stderr.write("Error getting information on patch ID %d\n" % \
@@ -293,6 +293,9 @@ def action_update_patch(rpc, patch_id, state = None, commit = None):
if commit:
params['commit_ref'] = commit
+ if archived:
+ params['archived'] = archived == 'yes'
+
success = False
try:
success = rpc.patch_set(patch_id, params)
@@ -371,6 +374,10 @@ def main():
help='''Filter by patch state (e.g., 'New', 'Accepted', etc.)'''
)
filter_parser.add_argument(
+ '-a', choices=['yes','no'],
+ help='''Filter by patch archived state'''
+ )
+ filter_parser.add_argument(
'-p', metavar='PROJECT',
help='''Filter by project name (see 'projects' for list)'''
)
@@ -486,6 +493,10 @@ def main():
required=True,
help='''Set patch state (e.g., 'Accepted', 'Superseded' etc.)'''
)
+ update_parser.add_argument(
+ '-a', choices=['yes', 'no'],
+ help='''Set patch archived state'''
+ )
update_parser.set_defaults(subcmd='update')
list_parser = subparsers.add_parser("list",
add_help=False,
@@ -525,6 +536,7 @@ def main():
commit_str = None
url = DEFAULT_URL
+ archived_str = args.get('a')
state_str = args.get('s')
project_str = args.get('p')
submitter_str = args.get('w')
@@ -630,6 +642,9 @@ def main():
if state_str:
filt.add("state", state_str)
+ if archived_str:
+ filt.add("archived", archived_str == 'yes')
+
if msgid_str:
filt.add("msgid", msgid_str)
@@ -702,7 +717,7 @@ def main():
elif action == 'update':
for patch_id in non_empty(h, patch_ids):
action_update_patch(rpc, patch_id, state = state_str,
- commit = commit_str
+ archived = archived_str, commit = commit_str
)
else:
--
2.2.0.rc2
_______________________________________________
Patchwork mailing list
Patchwork at lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork
More information about the Patchwork
mailing list