Skip to content

Commit 9fbae85

Browse files
committed
cli: Make cloudmonkey.py pep8 compliant
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
1 parent c75b11d commit 9fbae85

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

tools/cli/cloudmonkey/cloudmonkey.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -168,32 +168,32 @@ def printer_helper(printer, toprow):
168168
# result_filter - filterset
169169
# description: prints result as a json object
170170
def print_result_json(result, result_filter=None):
171-
tfilter = {} # temp var to hold a dict of the filters
172-
tresult = copy.deepcopy(result) # dupe the result to filter
173-
if result_filter != None:
171+
tfilter = {} # temp var to hold a dict of the filters
172+
tresult = copy.deepcopy(result) # dupe the result to filter
173+
if result_filter is not None:
174174
for res in result_filter:
175-
tfilter[ res ] = 1
175+
tfilter[res] = 1
176176
myresults = {}
177177
for okey, oval in result.iteritems():
178-
if isinstance( oval, dict ):
178+
if isinstance(oval, dict):
179179
for tkey in x:
180180
if tkey not in tfilter:
181181
try:
182-
del( tresult[okey][x][tkey] )
182+
del(tresult[okey][x][tkey])
183183
except:
184184
pass
185-
elif isinstance( oval, list ):
186-
for x in range( len( oval ) ):
187-
if isinstance( oval[x], dict ):
185+
elif isinstance(oval, list):
186+
for x in range(len(oval)):
187+
if isinstance(oval[x], dict):
188188
for tkey in oval[x]:
189189
if tkey not in tfilter:
190190
try:
191-
del( tresult[okey][x][tkey] )
191+
del(tresult[okey][x][tkey])
192192
except:
193193
pass
194194
else:
195195
try:
196-
del( tresult[ okey ][ x ] )
196+
del(tresult[okey][x])
197197
except:
198198
pass
199199
print json.dumps(tresult,
@@ -240,7 +240,8 @@ def print_result_as_dict(result, result_filter=None):
240240
def print_result_as_list(result, result_filter=None):
241241
for node in result:
242242
# Tabular print if it's a list of dict and tabularize is true
243-
if isinstance(node, dict) and (self.display == 'tabularize' or self.tabularize == 'true'):
243+
if isinstance(node, dict) and (self.display == 'tabularize' or
244+
self.tabularize == 'true'):
244245
print_result_tabular(result, result_filter)
245246
break
246247
self.print_result(node)
@@ -363,7 +364,9 @@ def completedefault(self, text, line, begidx, endidx):
363364
autocompletions = uuids
364365
search_string = value
365366

366-
if (self.display == "tabularize" or self.display == "json" or self.tabularize == "true") and subject != "":
367+
if subject != "" and (self.display == "tabularize" or
368+
self.display == "json" or
369+
self.tabularize == "true"):
367370
autocompletions.append("filter=")
368371
return [s for s in autocompletions if s.startswith(search_string)]
369372

@@ -504,6 +507,7 @@ def do_quit(self, args):
504507
self.monkeyprint("Bye!")
505508
return self.do_EOF(args)
506509

510+
507511
class MonkeyParser(OptionParser):
508512
def format_help(self, formatter=None):
509513
if formatter is None:
@@ -517,6 +521,7 @@ def format_help(self, formatter=None):
517521
result.append("\nTry cloudmonkey [help|?]\n")
518522
return "".join(result)
519523

524+
520525
def main():
521526
parser = MonkeyParser()
522527
parser.add_option("-c", "--config-file",

0 commit comments

Comments
 (0)