Commit c9836b5e by fwkz

Changing API for utils.pprint_dict_in_order() + fixing bug

parent 664bf247
...@@ -330,8 +330,8 @@ class RoutersploitInterpreter(BaseInterpreter): ...@@ -330,8 +330,8 @@ class RoutersploitInterpreter(BaseInterpreter):
sub_command = args[0] sub_command = args[0]
if sub_command == info: if sub_command == info:
utils.pprint_dict_in_order( utils.pprint_dict_in_order(
("name", "description", "targets", "authors", "references"),
self.module_metadata, self.module_metadata,
("name", "description", "targets", "authors", "references"),
) )
utils.print_info() utils.print_info()
elif sub_command == options: elif sub_command == options:
......
...@@ -201,13 +201,13 @@ def sanitize_url(address): ...@@ -201,13 +201,13 @@ def sanitize_url(address):
return url return url
def pprint_dict_in_order(order, dictionary): def pprint_dict_in_order(dictionary, order=None):
""" Pretty dict print. """ Pretty dict print.
Pretty printing dictionary in specific order. (as in 'show info' command) Pretty printing dictionary in specific order. (as in 'show info' command)
Keys not mentioned in *order* parameter will be printed in random order. Keys not mentioned in *order* parameter will be printed in random order.
ex. pprint_dict_in_order(('sex', 'name'), {'name': John, 'sex': 'male', "hobby": ["rugby", "golf"]}) ex. pprint_dict_in_order({'name': John, 'sex': 'male', "hobby": ["rugby", "golf"]}, ('sex', 'name'))
Sex: Sex:
male male
...@@ -220,6 +220,8 @@ def pprint_dict_in_order(order, dictionary): ...@@ -220,6 +220,8 @@ def pprint_dict_in_order(order, dictionary):
- golf - golf
""" """
order = order or ()
def prettyprint(title, body): def prettyprint(title, body):
print_info("\n{}:".format(title.capitalize())) print_info("\n{}:".format(title.capitalize()))
if not isinstance(body, str): if not isinstance(body, str):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment