示例#1
0
    def stat_complexity(function):
        
        lines = inspect.getsourcelines(function)[0][1:]
        n_lines = Analyzer.normalize(lines)
        ops_dict, opns_dict  = Analyzer.calc_operators(n_lines)
        prog_dict = Analyzer.calc_program(ops_dict, opns_dict)
            # Analyzer.print_(operators = ops_dict, operands= opns_dict, program = prog_dict)
        a_dict = {'operators': ops_dict, 'operands': opns_dict, 'program': prog_dict}

        printer = PdfPrinter()
        printer.print_dictionaries(a_dict)

        printer.print_bar_chart("Code metrics", "params", "values", prog_dict)
        printer.save_file(function.__name__ + "_complexity.pdf")
        # print(a_dict)

        return function
示例#2
0
        def wrapper():

            lines = ''.join(inspect.getsourcelines(function)[0][1:])
            args = ''
            kwargs = ''

            if hasattr(function, 'args'):
                args = getattr(function, args)
            if hasattr(function, 'kwargs'):
                kwargs = getattr(function, 'kwargs')

            out = io.StringIO()
            with redirect_stdout(out):
                if args != '' and kwargs != '':
                    function(args, kwargs)
                elif args != '':
                    function(args)
                elif kwargs != '':
                    function(kwargs)
                else:
                    function()

            o_dict = {
                'Name': function.__name__,
                'Type': str(type(function)),
                'Sign': str(inspect.signature(function)),
                'Args':
                ('positional ' + str(args), 'key=worded ' + str(kwargs)),
                'Doc': str(function.__doc__),
                'Source': lines[1:],
                'Out': out.getvalue()
            }

            printer = PdfPrinter()
            printer.print_dictionaries(o_dict)

            # printer.print_bar_chart("Code metrics", "params", "values", o_dict)
            printer.save_file(function.__name__ + "_stat.pdf")
示例#3
0
from PdfGenerator import PdfPrinter

printer = PdfPrinter()
printer.print_dictionaries({
    "A": {
        "A1": "Bdjbhalsbdzg \n aibsdvaibvdsavipdbv \nf wpijwnbi ip \n",
        "A2": "B2"
    },
    "V": "C1"
})
#printer.print_bar_chart("test", "x","y", {"A":1,"B":2})
printer.save_file("change_fonts.pdf")
示例#4
0
from PdfGenerator import PdfPrinter

printer = PdfPrinter()
printer.print_dictionaries({"A" : { "A1" : "B1" , "A2":"B2"}, "V" : "C1"})
printer.save_file("change_fonts.pdf")
示例#5
0
        def wrapper():

            lines = ''.join(inspect.getsourcelines(function)[0][1:])
            args = ''
            kwargs = ''

            if is_func:
                if hasattr(function, 'args'):
                    args = getattr(function, args)
                if hasattr(function, 'kwargs'):
                    kwargs = getattr(function, 'kwargs')

            out = io.StringIO()

            if is_func:
                with redirect_stdout(out):
                    if args != '' and kwargs != '':
                        function(args, kwargs)
                    elif args != '':
                        function(args)
                    elif kwargs != '':
                        function(kwargs)
                    else:
                        function()

            o_dict = ''

            if is_func:
                o_dict = {
                    'Name':
                    function.__name__,
                    'Type':
                    str(type(function)),
                    'Sign':
                    str(inspect.signature(function)),
                    'Args':
                    ('positional ' + str(args), 'key=worded ' + str(kwargs)),
                    'Doc':
                    str(function.__doc__),
                    'Source':
                    lines[1:],
                    'Out':
                    out.getvalue()
                }

            else:
                o_dict = {
                    'Name':
                    function.__name__,
                    'Type':
                    str(type(function)),
                    'Doc':
                    str(function.__doc__),
                    'Members':
                    str(
                        inspect.getmembers(
                            function, lambda a: not (inspect.isroutine(a)))),
                    'Source':
                    lines[1:]
                }

            printer = PdfPrinter()
            printer.print_dictionaries(o_dict)
            printer.save_file(function.__name__ + "_stat.pdf")
            # Reflection.print_reflection(Name = function.__name__,
            #                     Type = str(type(function)),
            #                     Sign = str(inspect.signature(function)),
            #                     Args = ('positional ' + str(args), 'key=worded ' + str(kwargs)),
            #                     Doc = str(function.__doc__),
            #                     Source = lines,
            #                     Out = out.getvalue())

            print(o_dict)