Ejemplo n.º 1
0
def main(argv):
    """ Entry point method """
    try:
        opts, args = getopt.getopt(argv[1:], "m:", ["metric="])
    except getopt.GetoptError:
        usage()
    
    for opt, arg in opts:
        if opt in ["-m", "--metric"]:
            use_metric = arg
        else:
            usage()
    
    if len(args) < 1:
        usage()
    elif args[0] == '-':
        input_files = [sys.stdin]
    else:
        input_files = []
        for arg in args:
            input_files.append(open(arg, 'r'))
    
    print('\n')

    text = ""
    
    for file in input_files:
        text = text + '\n' + file.read()
    
    if use_metric == 'holsted':
        h = holsted.Holsted(text)
        h.run()
    elif use_metric == 'myers':
        text = code_cleanup.cleanup_strings(code_cleanup.cleanup_sharp(code_cleanup.cleanup_comments(text)))
        g = graph.ExecGraph(text)
        g.build_graph()
        m = myers.Myers(g, text)
        m.analyze()
        print('Метрика Майерса:', m.metric())
    elif use_metric == 'boundary':
        text = code_cleanup.cleanup_strings(code_cleanup.cleanup_sharp(code_cleanup.cleanup_comments(text)))
        g = graph.ExecGraph(text)
        g.build_graph()
        b = boundary.Boundary(g)
        b.analyze()
        print('Метрика граничных значений:', b.metric())
Ejemplo n.º 2
0
 def __init__(self, code):
     self.text = code
     cleaned_code = code_cleanup.cleanup_sharp(code)
     cleaned_code = code_cleanup.cleanup_comments(cleaned_code)
     (cleaned_code, total_string_count, unique_string_count) = code_cleanup.cleanup_and_get_strings_count(cleaned_code)
     self.total_operands_count += total_string_count
     self.unique_operands_count += unique_string_count
     self.cleaned_code = cleaned_code
Ejemplo n.º 3
0
def main(argv):
    """ Entry point method """
    try:
        opts, args = getopt.getopt(argv[1:], "m:", ["metric="])
    except getopt.GetoptError:
        usage()
    
    for opt, arg in opts:
        if opt in ["-m", "--metric"]:
            use_metric = arg
        else:
            usage()
    
    if len(args) < 1:
        usage()
    elif args[0] == '-':
        input_files = [sys.stdin]
    else:
        input_files = []
        for arg in args:
            input_files.append(open(arg, 'r'))
    
    print('\n')

    text = ""
    
    for file in input_files:
        text = text + '\n' + file.read()
    
    if use_metric == 'holsted':
        h = holsted.Holsted(text)
        print (h.run())
    elif use_metric == 'myers':
        text = code_cleanup.cleanup_strings(code_cleanup.cleanup_sharp(code_cleanup.cleanup_comments(text)))
        g = graph.ExecGraph(text)
        g.build_graph()
        m = myers.Myers(g, text)
        m.analyze()
        print('Метрика Майерса:', m.metric())
    elif use_metric == 'boundary':
        text = code_cleanup.cleanup_strings(code_cleanup.cleanup_sharp(code_cleanup.cleanup_comments(text)))
        g = graph.ExecGraph(text)
        g.build_graph()
        b = boundary.Boundary(g)
        b.analyze()
        print('Метрика граничных значений:', b.metric())
Ejemplo n.º 4
0
 def __init__(self, code):
     self.text = code
     cleaned_code = code_cleanup.cleanup_sharp(code)
     cleaned_code = code_cleanup.cleanup_comments(cleaned_code)
     (cleaned_code, total_string_count, unique_string_count
      ) = code_cleanup.cleanup_and_get_strings_count(cleaned_code)
     self.total_operands_count += total_string_count
     self.unique_operands_count += unique_string_count
     self.cleaned_code = cleaned_code
Ejemplo n.º 5
0
def main(argv):
    """ Entry point method """
    try:
        opts, args = getopt.getopt(argv[1:], "m:", ["metric="])
    except getopt.GetoptError:
        usage()
    
    for opt, arg in opts:
        if opt in ["-m", "--metric"]:
            use_metric = arg
        else:
            usage()
    
    if len(args) != 1:
        usage()
    elif args[0] == '-':
        input_file = sys.stdin
    else:
        input_file = open(args[0], 'r')
    
    print(use_metric)

    print('\n')

    text = input_file.read()
    
    if use_metric == 'holsted':
        h = holsted.Holsted(text)
        h.run()
    elif use_metric == 'myers':
        text = code_cleanup.cleanup_strings(code_cleanup.cleanup_sharp(code_cleanup.cleanup_comments(text)))
        print(text)
        
        g = graph.ExecGraph(text)
        g.build_graph()
        print('\n*********************************************\n')
        print(g.filtered_text)
        print('\n*********************************************\n')
        g.print_tree()