예제 #1
0
def test_of_file_searching():
    File_of_code = pythonfiles.FileInDirectory()
    resultexpected = ['temp.dot']

    result = pythonfiles.FileInDirectory.list_directory(
        File_of_code, './', 'dot')

    assert result == resultexpected
예제 #2
0
def test_of_file_searching():
    File_of_code = pythonfiles.FileInDirectory()
    resultexpected = [
        'FilesClass.py', 'functions.py', 'FunctionsClass.py', 'main.py',
        'ModulesClass.py', 'python_files.py', 'RegistrationClass.py',
        'test_for_python.py'
    ]

    result = pythonfiles.FileInDirectory.list_directory(
        File_of_code, '.\\', 'py')

    assert result == resultexpected
예제 #3
0
"""
Moduł zawierający różne przydatne funckcje.
"""

from radon.complexity import cc_visit

import pythonfiles

FILES_WITH_CODE = pythonfiles.FileInDirectory()
PATH = r'.\\'
EXTEND = 'py'
RESLUT2 = FILES_WITH_CODE.list_directory(
    PATH,
    EXTEND)  # przeszukanie katalogu ,aby znaleźć pliki z rozszerzeniem py

MY_CATALOG = []  # lista przechowująca liste plików
for actual_element in RESLUT2:
    MY_CATALOG.append(actual_element.split('.')[0])


def counting_lines_of_code(element):
    """  funkcja podająca rozmiar pliku w linijkach kodu"""
    try:
        with open(PATH + '\\' + element, 'r') as open_file:
            lines = 0
            for line in open_file:
                if line != '\n':
                    lines += 1
            return lines

    except IndexError as error:
예제 #4
0
def main():
    """Funkcja wykonująca cały program"""
    modul = modules.Modules()
    fun = function.Functions()
    file = files.Files()
    register = registration.Registration()

    files_with_code = pythonfiles.FileInDirectory()
    path = r'.\\'
    extend = 'py'
    result = files_with_code.list_directory(path, extend)

    files.Files.checking_connections_between_files(result)

    function_list1 = function.Functions.checking_connections_between_functions1(
        result)
    function_list2 = fun.checking_weight_of_connections_between_functions(
        result, function_list1)
    weight_fun = functions.write_to_file_fun_data(function_list1,
                                                  function_list2)
    function.Functions.checking_connections_between_functions(
        result, weight_fun)
    modul_list = modules.Modules.searching_for_used_modules(result)
    modules.Modules.checking_connections_between_modules(result, modul_list)

    join_list = functions.convert_list_to_list_for_cc(
        files.Files.filesConnectionList, modules.Modules.modulConnectionList)
    join_list = list(set(join_list))

    cyclomatic_complexity = functions.cyclomatic_complexity()
    cyclomatic_complexity = functions.compare(function_list1,
                                              cyclomatic_complexity)
    cyclomatic_complexity += join_list
    menu_choice = functions.menu()

    if menu_choice == 1:
        registration.Registration.write_to_file(
            "FILES", files.Files.filesConnectionList
        )  # Wpisywanie do pliku połączeń plików
        registration.Registration.write_to_file(
            "", files.Files.filesConnectionWeight)

    elif menu_choice == 2:
        registration.Registration.write_to_file(
            "Functions", function.Functions.functionsConnectionList
        )  # Wpisywanie do pliku połączeń funkcji
        registration.Registration.write_to_file(
            "", function.Functions.functionsConnectionWeight)
        registration.Registration.write_to_file("CYCLOMATIC_COMPLEXITY",
                                                cyclomatic_complexity)

    elif menu_choice == 3:
        registration.Registration.write_to_file(
            "Modules", files.Files.filesConnectionList
        )  # Wpisywanie do pliku połączeń modułów
        registration.Registration.write_to_file(
            "", modul.Modules.modulConnectionWeight)

    elif menu_choice == 4:
        registration.Registration.write_to_file(
            "FILES", files.Files.filesConnectionList
        )  # Wpisywanie do pliku połączeń plików
        registration.Registration.write_to_file(
            "", files.Files.filesConnectionWeight)

        registration.Registration.write_to_file(
            "Functions", function.Functions.functionsConnectionList
        )  # Wpisywanie do pliku połączeń funkcji
        registration.Registration.write_to_file(
            "", function.Functions.functionsConnectionWeight)
        registration.Registration.write_to_file("CYCLOMATIC_COMPLEXITY",
                                                cyclomatic_complexity)

    elif menu_choice == 5:
        registration.Registration.write_to_file(
            "FILES", files.Files.filesConnectionList
        )  # Wpisywanie do pliku połączeń plików
        registration.Registration.write_to_file(
            "", files.Files.filesConnectionWeight)

        registration.Registration.write_to_file(
            "Modules", modules.Modules.modulConnectionList
        )  # Wpisywanie do pliku połączeń modułów
        registration.Registration.write_to_file(
            "", modules.Modules.modulConnectionWeight)

    elif menu_choice == 6:
        registration.Registration.write_to_file(
            "Functions", function.Functions.functionsConnectionList
        )  # Wpisywanie do pliku połączeń funkcji
        registration.Registration.write_to_file(
            "", function.Functions.functionsConnectionWeight)

        registration.Registration.write_to_file(
            "Modules", modules.Modules.modulConnectionList
        )  # Wpisywanie do pliku połączeń modułów
        registration.Registration.write_to_file(
            "", modules.Modules.modulConnectionWeight)
        registration.Registration.write_to_file("CYCLOMATIC_COMPLEXITY",
                                                cyclomatic_complexity)

    elif menu_choice == 7:
        registration.Registration.write_to_file(
            "FILES", files.Files.filesConnectionList
        )  # Wpisywanie do pliku połączeń plików
        registration.Registration.write_to_file(
            "", files.Files.filesConnectionWeight)

        registration.Registration.write_to_file(
            "Functions", function.Functions.functionsConnectionList
        )  # Wpisywanie do pliku połączeń funkcji
        registration.Registration.write_to_file(
            "", function.Functions.functionsConnectionWeight)

        registration.Registration.write_to_file(
            "Modules", modules.Modules.modulConnectionList
        )  # Wpisywanie do pliku połączeń modułów
        registration.Registration.write_to_file(
            "", modules.Modules.modulConnectionWeight)
        registration.Registration.write_to_file("CYCLOMATIC_COMPLEXITY",
                                                cyclomatic_complexity)

    else:
        print("Wybrałeś opcję z poza zakresu")
        main()