From 1777759dd0287c6d84878e71c9023ead55fa7eb9 Mon Sep 17 00:00:00 2001 From: Josselin Date: Fri, 15 Feb 2019 18:50:17 +0000 Subject: [PATCH] Add missing file --- slither/printers/summary/variable_order.py | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 slither/printers/summary/variable_order.py diff --git a/slither/printers/summary/variable_order.py b/slither/printers/summary/variable_order.py new file mode 100644 index 000000000..dac13301a --- /dev/null +++ b/slither/printers/summary/variable_order.py @@ -0,0 +1,31 @@ +""" + Module printing summary of the contract +""" + +from prettytable import PrettyTable +from slither.printers.abstract_printer import AbstractPrinter + +class VariableOrder(AbstractPrinter): + + ARGUMENT = 'variable-order' + HELP = 'Print the storage order of the state variables' + + WIKI = 'https://github.com/trailofbits/slither/wiki/Printer-documentation#variable-order' + + def output(self, _filename): + """ + _filename is not used + Args: + _filename(string) + """ + + txt = '' + for contract in self.slither.contracts_derived: + txt += '\n{}:\n'.format(contract.name) + table = PrettyTable(['Name', 'Type']) + for variable in contract.state_variables: + if not variable.is_constant: + table.add_row([variable.name, str(variable.type)]) + txt += str(table) + '\n' + + self.info(txt)