cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [2/3] git commit: updated refs/heads/master to ff74cbb
Date Fri, 05 Apr 2013 17:39:03 GMT
cli: Make cloudmonkey.py pep8 compliant

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9fbae857
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9fbae857
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9fbae857

Branch: refs/heads/master
Commit: 9fbae8579923ad7f2823c084e6112b406714652b
Parents: c75b11d
Author: Rohit Yadav <bhaisaab@apache.org>
Authored: Fri Apr 5 22:56:07 2013 +0530
Committer: Rohit Yadav <bhaisaab@apache.org>
Committed: Fri Apr 5 22:56:07 2013 +0530

----------------------------------------------------------------------
 tools/cli/cloudmonkey/cloudmonkey.py |   31 ++++++++++++++++------------
 1 files changed, 18 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9fbae857/tools/cli/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/tools/cli/cloudmonkey/cloudmonkey.py b/tools/cli/cloudmonkey/cloudmonkey.py
index 842af26..14d7d94 100644
--- a/tools/cli/cloudmonkey/cloudmonkey.py
+++ b/tools/cli/cloudmonkey/cloudmonkey.py
@@ -168,32 +168,32 @@ class CloudMonkeyShell(cmd.Cmd, object):
         #             result_filter - filterset
         # description: prints result as a json object
         def print_result_json(result, result_filter=None):
-            tfilter = {} # temp var to hold a dict of the filters
-            tresult = copy.deepcopy(result) # dupe the result to filter
-            if result_filter != None:
+            tfilter = {}  # temp var to hold a dict of the filters
+            tresult = copy.deepcopy(result)  # dupe the result to filter
+            if result_filter is not None:
                 for res in result_filter:
-                    tfilter[ res ] = 1
+                    tfilter[res] = 1
                 myresults = {}
                 for okey, oval in result.iteritems():
-                    if isinstance( oval, dict ):
+                    if isinstance(oval, dict):
                         for tkey in x:
                             if tkey not in tfilter:
                                 try:
-                                    del( tresult[okey][x][tkey] )
+                                    del(tresult[okey][x][tkey])
                                 except:
                                     pass
-                    elif isinstance( oval, list ):
-                        for x in range( len( oval ) ):
-                            if isinstance( oval[x], dict ):
+                    elif isinstance(oval, list):
+                        for x in range(len(oval)):
+                            if isinstance(oval[x], dict):
                                 for tkey in oval[x]:
                                     if tkey not in tfilter:
                                         try:
-                                            del( tresult[okey][x][tkey] )
+                                            del(tresult[okey][x][tkey])
                                         except:
                                             pass
                             else:
                                 try:
-                                    del( tresult[ okey ][ x ] )
+                                    del(tresult[okey][x])
                                 except:
                                     pass
             print json.dumps(tresult,
@@ -240,7 +240,8 @@ class CloudMonkeyShell(cmd.Cmd, object):
         def print_result_as_list(result, result_filter=None):
             for node in result:
                 # Tabular print if it's a list of dict and tabularize is true
-                if isinstance(node, dict) and (self.display == 'tabularize' or self.tabularize
== 'true'):
+                if isinstance(node, dict) and (self.display == 'tabularize' or
+                                               self.tabularize == 'true'):
                     print_result_tabular(result, result_filter)
                     break
                 self.print_result(node)
@@ -363,7 +364,9 @@ class CloudMonkeyShell(cmd.Cmd, object):
                     autocompletions = uuids
                     search_string = value
 
-        if (self.display == "tabularize" or self.display == "json" or self.tabularize ==
"true") and subject != "":
+        if subject != "" and (self.display == "tabularize" or
+                              self.display == "json" or
+                              self.tabularize == "true"):
             autocompletions.append("filter=")
         return [s for s in autocompletions if s.startswith(search_string)]
 
@@ -504,6 +507,7 @@ class CloudMonkeyShell(cmd.Cmd, object):
         self.monkeyprint("Bye!")
         return self.do_EOF(args)
 
+
 class MonkeyParser(OptionParser):
     def format_help(self, formatter=None):
         if formatter is None:
@@ -517,6 +521,7 @@ class MonkeyParser(OptionParser):
         result.append("\nTry cloudmonkey [help|?]\n")
         return "".join(result)
 
+
 def main():
     parser = MonkeyParser()
     parser.add_option("-c", "--config-file",


Mime
View raw message