]> git.ozlabs.org Git - patchwork/blobdiff - apps/patchwork/bin/pwclient
pwclient: rename variable CONFIG_FILES to be singular
[patchwork] / apps / patchwork / bin / pwclient
index 958861581815ca64094691cb8623383aa785ed76..2104f593f9ca37618d33cc4bee0530366aaea76a 100755 (executable)
@@ -34,7 +34,7 @@ import ConfigParser
 # for the URL to access.  If that is unspecified, it will fallback to
 # the hardcoded default value specified here.
 DEFAULT_URL = "http://patchwork/xmlrpc/"
-CONFIG_FILES = [os.path.expanduser('~/.pwclientrc')]
+CONFIG_FILE = os.path.expanduser('~/.pwclientrc')
 
 class Filter:
     """Filter for selecting patches."""
@@ -113,6 +113,7 @@ def usage():
 """        apply <ID>    : Apply a patch (in the current dir, using -p1)
         git-am <ID>   : Apply a patch to current git branch using "git am"
         get <ID>      : Download a patch and save it locally
+        info <ID>     : Display patchwork info about a given patch ID
         projects      : List all projects
         states        : Show list of potential patch states
         list [str]    : List patches, using the optional filters specified
@@ -164,10 +165,10 @@ def person_ids_by_name(rpc, name):
 
 def list_patches(patches):
     """Dump a list of patches to stdout."""
-    print("%-5s %-12s %s" % ("ID", "State", "Name"))
-    print("%-5s %-12s %s" % ("--", "-----", "----"))
+    print("%-7s %-12s %s" % ("ID", "State", "Name"))
+    print("%-7s %-12s %s" % ("--", "-----", "----"))
     for patch in patches:
-        print("%-5d %-12s %s" % (patch['id'], patch['state'], patch['name']))
+        print("%-7d %-12s %s" % (patch['id'], patch['state'], patch['name']))
 
 def action_list(rpc, filter, submitter_str, delegate_str):
     filter.resolve_ids(rpc)
@@ -224,6 +225,14 @@ def action_states(rpc):
     for state in states:
         print("%-5d %s" % (state['id'], state['name']))
 
+def action_info(rpc, patch_id):
+    patch = rpc.patch_get(patch_id)
+    s = "Information for patch id %d" % (patch_id)
+    print(s)
+    print('-' * len(s))
+    for key, value in sorted(patch.iteritems()):
+        print("- %- 14s: %s" % (key, unicode(value).encode("utf-8")))
+
 def action_get(rpc, patch_id):
     patch = rpc.patch_get(patch_id)
     s = rpc.patch_get_mbox(patch_id)
@@ -342,7 +351,7 @@ def main():
     url = DEFAULT_URL
 
     config = ConfigParser.ConfigParser()
-    config.read(CONFIG_FILES)
+    config.read([CONFIG_FILE])
 
     # grab settings from config files
     if config.has_option('base', 'url'):
@@ -443,14 +452,17 @@ def main():
         if len(s) > 0:
             print unicode(s).encode("utf-8")
 
-    elif action == 'get' or action == 'save':
+    elif action in ('get', 'save', 'info'):
         try:
             patch_id = patch_id or int(args[0])
         except:
             sys.stderr.write("Invalid patch ID given\n")
             sys.exit(1)
 
-        action_get(rpc, patch_id)
+        if action == 'info':
+            action_info(rpc, patch_id)
+        else:
+            action_get(rpc, patch_id)
 
     elif action == 'apply':
         try: