diff --git a/Makefile b/Makefile index 34f29920..7ed54321 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -UTIL_VERSION := 0.5.9 +UTIL_VERSION := 0.5.10 UTIL_NAME := codeplag PWD := $(shell pwd) diff --git a/locales/codeplag.pot b/locales/codeplag.pot index d51fa2f5..f300220f 100644 --- a/locales/codeplag.pot +++ b/locales/codeplag.pot @@ -1,14 +1,13 @@ # Translations template for codeplag. -# Copyright (C) 2024 Codeplag Development Team +# Copyright (C) 2024-2025 Codeplag Development Team # This file is distributed under the same license as the codeplag project. -# FIRST AUTHOR , 2024. # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: codeplag 0.5.8\n" +"Project-Id-Version: codeplag 0.5.10\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2024-10-18 23:58+0300\n" +"POT-Creation-Date: 2025-01-01 18:21+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Artyom Semidolin\n" "Language-Team: LANGUAGE \n" @@ -58,6 +57,10 @@ msgid "Show progress of searching plagiarism." msgstr "" #: src/codeplag/codeplagcli.py:133 +msgid "Do not show check works results in the stdout." +msgstr "" + +#: src/codeplag/codeplagcli.py:140 msgid "" "Threshold of analyzer which classifies two work as same. If this number " "is too large, such as 99, then completely matching jobs will be found. " @@ -65,138 +68,138 @@ msgid "" "minimal similarity will be found." msgstr "" -#: src/codeplag/codeplagcli.py:147 +#: src/codeplag/codeplagcli.py:154 msgid "The maximum depth of the AST structure which play role in calculations." msgstr "" -#: src/codeplag/codeplagcli.py:154 +#: src/codeplag/codeplagcli.py:161 msgid "" "The length of N-grams generated to calculate the Jakkar coefficient. A " "long length of N-grams reduces the Jakkar coefficient because there are " "fewer equal sequences of two works." msgstr "" -#: src/codeplag/codeplagcli.py:165 +#: src/codeplag/codeplagcli.py:172 msgid "The language of help messages, generated reports, errors." msgstr "" -#: src/codeplag/codeplagcli.py:171 +#: src/codeplag/codeplagcli.py:178 msgid "" "Sets the threshold for the '{util_name}' util loggers'. Logging messages " "that are less severe than the level will be ignored." msgstr "" -#: src/codeplag/codeplagcli.py:181 +#: src/codeplag/codeplagcli.py:188 msgid "The maximum number of processes that can be used to compare works." msgstr "" -#: src/codeplag/codeplagcli.py:189 +#: src/codeplag/codeplagcli.py:196 msgid "Show the '{util_name}' util settings." msgstr "" -#: src/codeplag/codeplagcli.py:193 +#: src/codeplag/codeplagcli.py:200 msgid "Start searching similar works." msgstr "" -#: src/codeplag/codeplagcli.py:199 +#: src/codeplag/codeplagcli.py:206 msgid "Absolute or relative path to a local directories with project files." msgstr "" -#: src/codeplag/codeplagcli.py:209 +#: src/codeplag/codeplagcli.py:216 msgid "Absolute or relative path to files on a computer." msgstr "" -#: src/codeplag/codeplagcli.py:216 +#: src/codeplag/codeplagcli.py:223 msgid "" "Choose one of the following modes of searching plagiarism. The " "'many_to_many' mode may require more free memory." msgstr "" -#: src/codeplag/codeplagcli.py:227 +#: src/codeplag/codeplagcli.py:234 msgid "" "A regular expression for filtering checked works by name. Used with " "options 'directories', 'github-user' and 'github-project-folders'." msgstr "" -#: src/codeplag/codeplagcli.py:236 +#: src/codeplag/codeplagcli.py:243 msgid "Ignore the threshold when checking of works." msgstr "" -#: src/codeplag/codeplagcli.py:243 +#: src/codeplag/codeplagcli.py:250 msgid "Extension responsible for the analyzed programming language." msgstr "" -#: src/codeplag/codeplagcli.py:253 +#: src/codeplag/codeplagcli.py:260 msgid "Searching in all branches." msgstr "" -#: src/codeplag/codeplagcli.py:260 +#: src/codeplag/codeplagcli.py:267 msgid "A regular expression to filter searching repositories on GitHub." msgstr "" -#: src/codeplag/codeplagcli.py:267 +#: src/codeplag/codeplagcli.py:274 msgid "URL to file in a GitHub repository." msgstr "" -#: src/codeplag/codeplagcli.py:273 +#: src/codeplag/codeplagcli.py:280 msgid "GitHub organization/user name." msgstr "" -#: src/codeplag/codeplagcli.py:280 +#: src/codeplag/codeplagcli.py:287 msgid "URL to a GitHub project folder." msgstr "" -#: src/codeplag/codeplagcli.py:290 +#: src/codeplag/codeplagcli.py:297 msgid "" "Handling generated by the {util_name} reports as creating html report " "file or show it on console." msgstr "" -#: src/codeplag/codeplagcli.py:298 +#: src/codeplag/codeplagcli.py:305 msgid "Report commands of the '{util_name}' util." msgstr "" -#: src/codeplag/codeplagcli.py:307 +#: src/codeplag/codeplagcli.py:314 msgid "Generate general report from created some time ago report files." msgstr "" -#: src/codeplag/codeplagcli.py:312 +#: src/codeplag/codeplagcli.py:319 msgid "" "Path to save generated report. If it's a directory, then create a file in" " it." msgstr "" -#: src/codeplag/codeplagcli.py:321 +#: src/codeplag/codeplagcli.py:328 msgid "Type of the created report file." msgstr "" -#: src/codeplag/codeplagcli.py:331 +#: src/codeplag/codeplagcli.py:338 msgid "" "Program help to find similar parts of source codes for the different " "languages." msgstr "" -#: src/codeplag/codeplagcli.py:339 +#: src/codeplag/codeplagcli.py:346 msgid "Print current version number and exit." msgstr "" -#: src/codeplag/codeplagcli.py:345 +#: src/codeplag/codeplagcli.py:352 msgid "Commands help." msgstr "" -#: src/codeplag/codeplagcli.py:360 +#: src/codeplag/codeplagcli.py:367 msgid "No command is provided; please choose one from the available (--help)." msgstr "" -#: src/codeplag/codeplagcli.py:371 +#: src/codeplag/codeplagcli.py:378 msgid "There is nothing to modify; please provide at least one argument." msgstr "" -#: src/codeplag/codeplagcli.py:375 +#: src/codeplag/codeplagcli.py:382 msgid "The'repo-regexp' option requires the provided 'github-user' option." msgstr "" -#: src/codeplag/codeplagcli.py:383 +#: src/codeplag/codeplagcli.py:390 msgid "" "The'path-regexp' option requires the provided 'directories', 'github-" "user', or 'github-project-folder' options." diff --git a/locales/translations/en/LC_MESSAGES/codeplag.po b/locales/translations/en/LC_MESSAGES/codeplag.po index 8725fc1c..68f0e665 100644 --- a/locales/translations/en/LC_MESSAGES/codeplag.po +++ b/locales/translations/en/LC_MESSAGES/codeplag.po @@ -1,11 +1,10 @@ # English translations for codeplag. -# Copyright (C) 2024 Codeplag Development Team +# Copyright (C) 2024-2025 Codeplag Development Team # This file is distributed under the same license as the codeplag project. -# FIRST AUTHOR , 2024. # msgid "" msgstr "" -"Project-Id-Version: codeplag 0.5.8\n" +"Project-Id-Version: codeplag 0.5.10\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "POT-Creation-Date: 2024-05-21 09:28+0300\n" "PO-Revision-Date: 2024-05-16 19:15+0300\n" @@ -59,6 +58,10 @@ msgid "Show progress of searching plagiarism." msgstr "Show progress of searching plagiarism." #: src/codeplag/codeplagcli.py:133 +msgid "Do not show check works results in the stdout." +msgstr "Do not show check works results in the stdout." + +#: src/codeplag/codeplagcli.py:140 msgid "" "Threshold of analyzer which classifies two work as same. If this number " "is too large, such as 99, then completely matching jobs will be found. " @@ -70,11 +73,11 @@ msgstr "" "Otherwise, if this number is small, such as 50, then all work with " "minimal similarity will be found." -#: src/codeplag/codeplagcli.py:147 +#: src/codeplag/codeplagcli.py:154 msgid "The maximum depth of the AST structure which play role in calculations." msgstr "The maximum depth of the AST structure which play role in calculations." -#: src/codeplag/codeplagcli.py:154 +#: src/codeplag/codeplagcli.py:161 msgid "" "The length of N-grams generated to calculate the Jakkar coefficient. A " "long length of N-grams reduces the Jakkar coefficient because there are " @@ -84,11 +87,11 @@ msgstr "" "long length of N-grams reduces the Jakkar coefficient because there are " "fewer equal sequences of two works." -#: src/codeplag/codeplagcli.py:165 +#: src/codeplag/codeplagcli.py:172 msgid "The language of help messages, generated reports, errors." msgstr "The language of help messages, generated reports, errors." -#: src/codeplag/codeplagcli.py:171 +#: src/codeplag/codeplagcli.py:178 msgid "" "Sets the threshold for the '{util_name}' util loggers'. Logging messages " "that are less severe than the level will be ignored." @@ -96,27 +99,27 @@ msgstr "" "Sets the threshold for the '{util_name}' util loggers'. Logging messages " "that are less severe than the level will be ignored." -#: src/codeplag/codeplagcli.py:181 +#: src/codeplag/codeplagcli.py:188 msgid "The maximum number of processes that can be used to compare works." msgstr "The maximum number of processes that can be used to compare works." -#: src/codeplag/codeplagcli.py:189 +#: src/codeplag/codeplagcli.py:196 msgid "Show the '{util_name}' util settings." msgstr "Show the '{util_name}' util settings." -#: src/codeplag/codeplagcli.py:193 +#: src/codeplag/codeplagcli.py:200 msgid "Start searching similar works." msgstr "Start searching similar works." -#: src/codeplag/codeplagcli.py:199 +#: src/codeplag/codeplagcli.py:206 msgid "Absolute or relative path to a local directories with project files." msgstr "Absolute or relative path to a local directories with project files." -#: src/codeplag/codeplagcli.py:209 +#: src/codeplag/codeplagcli.py:216 msgid "Absolute or relative path to files on a computer." msgstr "Absolute or relative path to files on a computer." -#: src/codeplag/codeplagcli.py:216 +#: src/codeplag/codeplagcli.py:223 msgid "" "Choose one of the following modes of searching plagiarism. The " "'many_to_many' mode may require more free memory." @@ -124,7 +127,7 @@ msgstr "" "Choose one of the following modes of searching plagiarism. The " "'many_to_many' mode may require more free memory." -#: src/codeplag/codeplagcli.py:227 +#: src/codeplag/codeplagcli.py:234 msgid "" "A regular expression for filtering checked works by name. Used with " "options 'directories', 'github-user' and 'github-project-folders'." @@ -132,35 +135,35 @@ msgstr "" "A regular expression for filtering checked works by name. Used with " "options 'directories', 'github-user' and 'github-project-folders'." -#: src/codeplag/codeplagcli.py:236 +#: src/codeplag/codeplagcli.py:243 msgid "Ignore the threshold when checking of works." msgstr "Ignore the threshold when checking of works." -#: src/codeplag/codeplagcli.py:243 +#: src/codeplag/codeplagcli.py:250 msgid "Extension responsible for the analyzed programming language." msgstr "Extension responsible for the analyzed programming language." -#: src/codeplag/codeplagcli.py:253 +#: src/codeplag/codeplagcli.py:260 msgid "Searching in all branches." msgstr "Searching in all branches." -#: src/codeplag/codeplagcli.py:260 +#: src/codeplag/codeplagcli.py:267 msgid "A regular expression to filter searching repositories on GitHub." msgstr "A regular expression to filter searching repositories on GitHub." -#: src/codeplag/codeplagcli.py:267 +#: src/codeplag/codeplagcli.py:274 msgid "URL to file in a GitHub repository." msgstr "URL to file in a GitHub repository." -#: src/codeplag/codeplagcli.py:273 +#: src/codeplag/codeplagcli.py:280 msgid "GitHub organization/user name." msgstr "GitHub organization/user name." -#: src/codeplag/codeplagcli.py:280 +#: src/codeplag/codeplagcli.py:287 msgid "URL to a GitHub project folder." msgstr "URL to a GitHub project folder." -#: src/codeplag/codeplagcli.py:290 +#: src/codeplag/codeplagcli.py:297 msgid "" "Handling generated by the {util_name} reports as creating html report " "file or show it on console." @@ -168,15 +171,15 @@ msgstr "" "Handling generated by the {util_name} reports as creating html report " "file or show it on console." -#: src/codeplag/codeplagcli.py:298 +#: src/codeplag/codeplagcli.py:305 msgid "Report commands of the '{util_name}' util." msgstr "Report commands of the '{util_name}' util." -#: src/codeplag/codeplagcli.py:307 +#: src/codeplag/codeplagcli.py:314 msgid "Generate general report from created some time ago report files." msgstr "Generate general report from created some time ago report files." -#: src/codeplag/codeplagcli.py:312 +#: src/codeplag/codeplagcli.py:319 msgid "" "Path to save generated report. If it's a directory, then create a file in" " it." @@ -184,11 +187,11 @@ msgstr "" "Path to save generated report. If it's a directory, then create a file in" " it." -#: src/codeplag/codeplagcli.py:321 +#: src/codeplag/codeplagcli.py:328 msgid "Type of the created report file." msgstr "Type of the created report file." -#: src/codeplag/codeplagcli.py:331 +#: src/codeplag/codeplagcli.py:338 msgid "" "Program help to find similar parts of source codes for the different " "languages." @@ -196,27 +199,27 @@ msgstr "" "Program help to find similar parts of source codes for the different " "languages." -#: src/codeplag/codeplagcli.py:339 +#: src/codeplag/codeplagcli.py:346 msgid "Print current version number and exit." msgstr "Print current version number and exit." -#: src/codeplag/codeplagcli.py:345 +#: src/codeplag/codeplagcli.py:352 msgid "Commands help." msgstr "Commands help." -#: src/codeplag/codeplagcli.py:360 +#: src/codeplag/codeplagcli.py:367 msgid "No command is provided; please choose one from the available (--help)." msgstr "No command is provided; please choose one from the available (--help)." -#: src/codeplag/codeplagcli.py:371 +#: src/codeplag/codeplagcli.py:378 msgid "There is nothing to modify; please provide at least one argument." msgstr "There is nothing to modify; please provide at least one argument." -#: src/codeplag/codeplagcli.py:375 +#: src/codeplag/codeplagcli.py:382 msgid "The'repo-regexp' option requires the provided 'github-user' option." msgstr "The'repo-regexp' option requires the provided 'github-user' option." -#: src/codeplag/codeplagcli.py:383 +#: src/codeplag/codeplagcli.py:390 msgid "" "The'path-regexp' option requires the provided 'directories', 'github-" "user', or 'github-project-folder' options." diff --git a/locales/translations/ru/LC_MESSAGES/codeplag.po b/locales/translations/ru/LC_MESSAGES/codeplag.po index 6f0a4f05..951278cb 100644 --- a/locales/translations/ru/LC_MESSAGES/codeplag.po +++ b/locales/translations/ru/LC_MESSAGES/codeplag.po @@ -1,11 +1,10 @@ # Russian translations for codeplag. -# Copyright (C) 2024 Codeplag Development Team +# Copyright (C) 2024-2025 Codeplag Development Team # This file is distributed under the same license as the codeplag project. -# FIRST AUTHOR , 2024. # msgid "" msgstr "" -"Project-Id-Version: codeplag 0.5.8\n" +"Project-Id-Version: codeplag 0.5.10\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "POT-Creation-Date: 2024-05-21 09:28+0300\n" "PO-Revision-Date: 2024-05-11 12:05+0300\n" @@ -64,6 +63,10 @@ msgid "Show progress of searching plagiarism." msgstr "Показывать прогресс выполнения поиска схожих работ." #: src/codeplag/codeplagcli.py:133 +msgid "Do not show check works results in the stdout." +msgstr "Не показывать результаты проверки в stdout." + +#: src/codeplag/codeplagcli.py:140 msgid "" "Threshold of analyzer which classifies two work as same. If this number " "is too large, such as 99, then completely matching jobs will be found. " @@ -76,11 +79,11 @@ msgstr "" "будет невелико, например, 50, то будут найдены все работы с минимальным " "сходством." -#: src/codeplag/codeplagcli.py:147 +#: src/codeplag/codeplagcli.py:154 msgid "The maximum depth of the AST structure which play role in calculations." msgstr "Максимальная глубина структуры AST, учитываемая при структурном сравнении." -#: src/codeplag/codeplagcli.py:154 +#: src/codeplag/codeplagcli.py:161 msgid "" "The length of N-grams generated to calculate the Jakkar coefficient. A " "long length of N-grams reduces the Jakkar coefficient because there are " @@ -90,11 +93,11 @@ msgstr "" "Большая длина N-грамм уменьшает коэффициент Жаккара, поскольку количество" " одинаковых последовательностей из двух работ становится меньше." -#: src/codeplag/codeplagcli.py:165 +#: src/codeplag/codeplagcli.py:172 msgid "The language of help messages, generated reports, errors." msgstr "Язык справочных сообщений, сгенерированных отчетов, ошибок." -#: src/codeplag/codeplagcli.py:171 +#: src/codeplag/codeplagcli.py:178 msgid "" "Sets the threshold for the '{util_name}' util loggers'. Logging messages " "that are less severe than the level will be ignored." @@ -103,29 +106,29 @@ msgstr "" "Сообщения, которые менее серьезны, чем это значение, будут " "игнорироваться." -#: src/codeplag/codeplagcli.py:181 +#: src/codeplag/codeplagcli.py:188 msgid "The maximum number of processes that can be used to compare works." msgstr "" "Максимальное количество процессов, которые можно задействовать для " "сравнения работ." -#: src/codeplag/codeplagcli.py:189 +#: src/codeplag/codeplagcli.py:196 msgid "Show the '{util_name}' util settings." msgstr "Показать настройки утилиты '{util_name}'." -#: src/codeplag/codeplagcli.py:193 +#: src/codeplag/codeplagcli.py:200 msgid "Start searching similar works." msgstr "Начать поиск схожих работ." -#: src/codeplag/codeplagcli.py:199 +#: src/codeplag/codeplagcli.py:206 msgid "Absolute or relative path to a local directories with project files." msgstr "Абсолютный или относительный путь к локальным папкам с файлами проекта." -#: src/codeplag/codeplagcli.py:209 +#: src/codeplag/codeplagcli.py:216 msgid "Absolute or relative path to files on a computer." msgstr "Абсолютный или относительный путь к файлам на компьютере." -#: src/codeplag/codeplagcli.py:216 +#: src/codeplag/codeplagcli.py:223 msgid "" "Choose one of the following modes of searching plagiarism. The " "'many_to_many' mode may require more free memory." @@ -133,7 +136,7 @@ msgstr "" "Выберите один из следующих режимов поиска схожих работ. Режим " "'many_to_many' может требовать больше свободной памяти." -#: src/codeplag/codeplagcli.py:227 +#: src/codeplag/codeplagcli.py:234 msgid "" "A regular expression for filtering checked works by name. Used with " "options 'directories', 'github-user' and 'github-project-folders'." @@ -142,35 +145,35 @@ msgstr "" "Используется с аргументами 'directories', 'github-user' или 'github-" "project-folders'." -#: src/codeplag/codeplagcli.py:236 +#: src/codeplag/codeplagcli.py:243 msgid "Ignore the threshold when checking of works." msgstr "Игнорировать пороговое значение при проверке работ." -#: src/codeplag/codeplagcli.py:243 +#: src/codeplag/codeplagcli.py:250 msgid "Extension responsible for the analyzed programming language." msgstr "Расширение проверяемых работ." -#: src/codeplag/codeplagcli.py:253 +#: src/codeplag/codeplagcli.py:260 msgid "Searching in all branches." msgstr "Поиск по всем веткам." -#: src/codeplag/codeplagcli.py:260 +#: src/codeplag/codeplagcli.py:267 msgid "A regular expression to filter searching repositories on GitHub." msgstr "Регулярное выражение для фильтрации искомых репозиториев на GitHub." -#: src/codeplag/codeplagcli.py:267 +#: src/codeplag/codeplagcli.py:274 msgid "URL to file in a GitHub repository." msgstr "URL до файла в репозитории на GitHub." -#: src/codeplag/codeplagcli.py:273 +#: src/codeplag/codeplagcli.py:280 msgid "GitHub organization/user name." msgstr "Название организации или имя пользователя на GitHub." -#: src/codeplag/codeplagcli.py:280 +#: src/codeplag/codeplagcli.py:287 msgid "URL to a GitHub project folder." msgstr "URL до какой-либо папки проекта на GitHub." -#: src/codeplag/codeplagcli.py:290 +#: src/codeplag/codeplagcli.py:297 msgid "" "Handling generated by the {util_name} reports as creating html report " "file or show it on console." @@ -178,15 +181,15 @@ msgstr "" "Обработка отчетов, сгенерированных с помощью {util_name}, в виде создания" " файла отчета в формате html или отображения его на консоли." -#: src/codeplag/codeplagcli.py:298 +#: src/codeplag/codeplagcli.py:305 msgid "Report commands of the '{util_name}' util." msgstr "Команды для работы с отчётами утилиты '{util_name}'." -#: src/codeplag/codeplagcli.py:307 +#: src/codeplag/codeplagcli.py:314 msgid "Generate general report from created some time ago report files." msgstr "Создание общего отчёта из созданных ранее файлов отчётов." -#: src/codeplag/codeplagcli.py:312 +#: src/codeplag/codeplagcli.py:319 msgid "" "Path to save generated report. If it's a directory, then create a file in" " it." @@ -194,11 +197,11 @@ msgstr "" "Путь для сохранения созданного отчёта. Если передан путь до папки, то " "создаёт отчёт в ней." -#: src/codeplag/codeplagcli.py:321 +#: src/codeplag/codeplagcli.py:328 msgid "Type of the created report file." msgstr "Тип создаваемого файла отчёта." -#: src/codeplag/codeplagcli.py:331 +#: src/codeplag/codeplagcli.py:338 msgid "" "Program help to find similar parts of source codes for the different " "languages." @@ -206,31 +209,31 @@ msgstr "" "Программа помогает находить схожие части исходных кодов для разных языков" " программирования." -#: src/codeplag/codeplagcli.py:339 +#: src/codeplag/codeplagcli.py:346 msgid "Print current version number and exit." msgstr "Выводит текущую версию программы." -#: src/codeplag/codeplagcli.py:345 +#: src/codeplag/codeplagcli.py:352 msgid "Commands help." msgstr "Справка по командам." -#: src/codeplag/codeplagcli.py:360 +#: src/codeplag/codeplagcli.py:367 msgid "No command is provided; please choose one from the available (--help)." msgstr "" "Ни одна из команд не выбрана, пожалуйста, выбери одну из доступных команд" " (--help)." -#: src/codeplag/codeplagcli.py:371 +#: src/codeplag/codeplagcli.py:378 msgid "There is nothing to modify; please provide at least one argument." msgstr "" "Нечего модифицировать, пожалуйста, выберите один из параметров для " "модификации." -#: src/codeplag/codeplagcli.py:375 +#: src/codeplag/codeplagcli.py:382 msgid "The'repo-regexp' option requires the provided 'github-user' option." msgstr "Аргумент 'repo-regexp' требует заданного параметра 'github-user'." -#: src/codeplag/codeplagcli.py:383 +#: src/codeplag/codeplagcli.py:390 msgid "" "The'path-regexp' option requires the provided 'directories', 'github-" "user', or 'github-project-folder' options." diff --git a/src/codeplag/codeplagcli.py b/src/codeplag/codeplagcli.py index 40508a79..ef7c8db0 100644 --- a/src/codeplag/codeplagcli.py +++ b/src/codeplag/codeplagcli.py @@ -127,6 +127,13 @@ def __add_settings_path(self: Self, subparsers: argparse._SubParsersAction) -> N type=int, choices=[0, 1], ) + settings_modify.add_argument( + "-so", + "--short-output", + help=_("Do not show check works results in the stdout."), + type=int, + choices=[0, 1], + ) settings_modify.add_argument( "-t", "--threshold", diff --git a/src/codeplag/config.py b/src/codeplag/config.py index 4d979736..1ef1ac7b 100644 --- a/src/codeplag/config.py +++ b/src/codeplag/config.py @@ -85,6 +85,7 @@ def write_settings_conf(settings: Settings) -> None: max_depth=DEFAULT_MAX_DEPTH, ngrams_length=DEFAULT_NGRAMS_LENGTH, show_progress=0, + short_output=0, reports_extension=DEFAULT_REPORT_EXTENSION, language=DEFAULT_LANGUAGE, log_level=DEFAULT_LOG_LEVEL, diff --git a/src/codeplag/handlers/check.py b/src/codeplag/handlers/check.py index 79acacb9..3e4f9aa7 100644 --- a/src/codeplag/handlers/check.py +++ b/src/codeplag/handlers/check.py @@ -3,7 +3,7 @@ import logging import math import os -from concurrent.futures import Future, ProcessPoolExecutor +from concurrent.futures import Future, ProcessPoolExecutor, as_completed from datetime import timedelta from itertools import combinations from pathlib import Path @@ -43,7 +43,7 @@ MaxDepth, Mode, NgramsLength, - ProcessingWorksInfo, + ProcessingWorks, Threshold, ) from webparsers.github_parser import GitHubParser @@ -90,6 +90,7 @@ def __init__( settings_conf = read_settings_conf() self.show_progress: Flag = settings_conf["show_progress"] + self.short_output: Flag = settings_conf["short_output"] self.threshold: Threshold | None = settings_conf["threshold"] self.workers: int = settings_conf["workers"] self.ngrams_length: NgramsLength = settings_conf.get( @@ -212,13 +213,14 @@ def __many_to_many_check( ) self.progress = Progress(iterations) with ProcessPoolExecutor(max_workers=self.workers) as executor: - processed: list[ProcessingWorksInfo] = [] + processing: list[ProcessingWorks] = [] + futures: set[Future] = set() for i, work1 in enumerate(works): for j, work2 in enumerate(works): if i <= j: continue - self._do_step(executor, processed, work1, work2) - self._handle_completed_futures(processed) + self._do_step(executor, processing, futures, work1, work2) + self._handle_completed_futures(processing, futures) def __one_to_one_check( self: Self, @@ -252,7 +254,8 @@ def __one_to_one_check( self.progress = ComplexProgress(iterations) cases = combinations(combined_elements, r=2) with ProcessPoolExecutor(max_workers=self.workers) as executor: - processed: list[ProcessingWorksInfo] = [] + processing: list[ProcessingWorks] = [] + futures: set[Future] = set() for internal_iteration, case in enumerate(cases, start=1): first_sequence, second_sequence = case if self.progress is not None: @@ -266,13 +269,14 @@ def __one_to_one_check( self.progress.add_internal_progress(internal_iterations) for work1 in first_sequence: for work2 in second_sequence: - self._do_step(executor, processed, work1, work2) - self._handle_completed_futures(processed) + self._do_step(executor, processing, futures, work1, work2) + self._handle_completed_futures(processing, futures) def _do_step( self: Self, executor: ProcessPoolExecutor, - processing: list[ProcessingWorksInfo], + processing: list[ProcessingWorks], + futures: set[Future], work1: ASTFeatures, work2: ASTFeatures, ) -> None: @@ -285,11 +289,10 @@ def _do_step( if isinstance(self.reporter, CSVReporter): metrics = self.reporter.get_compare_result_from_cache(work1, work2) if metrics is None: - processing.append( - ProcessingWorksInfo( - work1, work2, self._create_future_compare(executor, work1, work2) - ) - ) + future = self._create_future_compare(executor, work1, work2) + future.id = len(processing) # type: ignore + futures.add(future) + processing.append(ProcessingWorks(work1, work2)) return self._handle_compare_result(work1, work2, metrics) _print_pretty_progress_if_need_and_increase(self.progress, self.workers) @@ -305,6 +308,8 @@ def _handle_compare_result( return if self.reporter and save: self.reporter.save_result(work1, work2, metrics) + if self.short_output: + return if self.threshold and (metrics.structure.similarity * 100) <= self.threshold: print_compare_result(work1, work2, metrics) @@ -322,10 +327,12 @@ def _handle_compare_result( def _handle_completed_futures( self: Self, - processing: list[ProcessingWorksInfo], + processing: list[ProcessingWorks], + futures: set[Future], ) -> None: - for proc_works_info in processing: - metrics: CompareInfo = proc_works_info.compare_future.result() + for future in as_completed(futures): + metrics: CompareInfo = future.result() + proc_works_info = processing[future.id] # type: ignore self._handle_compare_result( proc_works_info.work1, proc_works_info.work2, metrics, save=True ) diff --git a/src/codeplag/types.py b/src/codeplag/types.py index f320a3b4..0397d790 100644 --- a/src/codeplag/types.py +++ b/src/codeplag/types.py @@ -1,6 +1,5 @@ import hashlib from collections import defaultdict -from concurrent.futures import Future from dataclasses import dataclass, field from datetime import datetime from functools import total_ordering @@ -150,6 +149,7 @@ class Settings(TypedDict): reports: NotRequired[Path] reports_extension: ReportsExtension show_progress: Flag + short_output: Flag max_depth: MaxDepth ngrams_length: NgramsLength threshold: Threshold @@ -161,10 +161,9 @@ class SameHead(NamedTuple): percent: float -class ProcessingWorksInfo(NamedTuple): +class ProcessingWorks(NamedTuple): work1: ASTFeatures work2: ASTFeatures - compare_future: Future SameFuncs = dict[str, list[SameHead]] diff --git a/test/auto/functional/test_settings.py b/test/auto/functional/test_settings.py index 17c77df9..ddf2dd05 100644 --- a/test/auto/functional/test_settings.py +++ b/test/auto/functional/test_settings.py @@ -1,14 +1,13 @@ import json import os from pathlib import Path -from typing import Literal import pytest from typing_extensions import Self from utils import MaxDepth, NgramsLength, modify_settings from codeplag.consts import CONFIG_PATH, NGRAMS_LENGTH_CHOICE, UTIL_NAME -from codeplag.types import Language, LogLevel, ReportsExtension, Threshold +from codeplag.types import Flag, Language, LogLevel, ReportsExtension, Threshold @pytest.fixture(scope="module", autouse=True) @@ -21,11 +20,11 @@ def teardown(): class TestSettingsModify: @pytest.mark.parametrize( - "env,reports,threshold,max_depth,ngrams_length,show_progress,reports_extension,language,log_level,workers", + "env,reports,threshold,max_depth,ngrams_length,show_progress,short_output,reports_extension,language,log_level,workers", [ - (f"src/{UTIL_NAME}/types.py", "src", 83, 6, 2, 0, "csv", "en", "debug", 1), - ("setup.py", "test", 67, 7, 3, 1, "csv", "ru", "info", os.cpu_count() or 1), - (f"src/{UTIL_NAME}/utils.py", "debian", 93, 8, 4, 0, "csv", "en", "warning", 1), + (f"src/{UTIL_NAME}/types.py", "src", 83, 6, 2, 0, 0, "csv", "en", "debug", 1), + ("setup.py", "test", 67, 7, 3, 1, 1, "csv", "ru", "info", os.cpu_count() or 1), + (f"src/{UTIL_NAME}/utils.py", "debian", 93, 8, 4, 0, 1, "csv", "en", "warning", 1), ], ) def test_modify_settings( @@ -35,7 +34,8 @@ def test_modify_settings( threshold: Threshold, max_depth: MaxDepth, ngrams_length: NgramsLength, - show_progress: Literal[0, 1], + show_progress: Flag, + short_output: Flag, reports_extension: ReportsExtension, language: Language, log_level: LogLevel, @@ -48,6 +48,7 @@ def test_modify_settings( max_depth=max_depth, ngrams_length=ngrams_length, show_progress=show_progress, + short_output=short_output, reports_extension=reports_extension, language=language, log_level=log_level, @@ -62,6 +63,7 @@ def test_modify_settings( "max_depth": max_depth, "ngrams_length": ngrams_length, "show_progress": show_progress, + "short_output": short_output, "workers": workers, "language": language, "log_level": log_level, @@ -69,25 +71,36 @@ def test_modify_settings( } @pytest.mark.parametrize( - "env,reports,threshold,log_level", + "env,reports,threshold,log_level,short_output", [ - (".env", "src", 101, "debug"), - ("setup.py", "test983hskdfue", 67, "info"), - (f"src/{UTIL_NAME}/utils.pyjlsieuow0", "debian", 93, "warning"), - (f"src/{UTIL_NAME}/types.py", "src", 83, "foobar"), + (".env", "src", 101, "debug", 0), + ("setup.py", "test983hskdfue", 67, "info", 0), + (f"src/{UTIL_NAME}/utils.pyjlsieuow0", "debian", 93, "warning", 0), + (f"src/{UTIL_NAME}/types.py", "src", 83, "foobar", 0), + (f"src/{UTIL_NAME}/types.py", "src", 83, "info", 2), ], ids=[ "Incorrect threshold.", "Path to reports doesn't exists.", "Path to environment doesn't exists.", "Invalid log level.", + "Invalid short-output.", ], ) def test_modify_settings_with_invalid_arguments( - self: Self, env: str, reports: str, threshold: Threshold, log_level: LogLevel + self: Self, + env: str, + reports: str, + threshold: Threshold, + log_level: LogLevel, + short_output: Flag, ) -> None: modify_settings( - environment=env, reports=reports, threshold=threshold, log_level=log_level + environment=env, + reports=reports, + threshold=threshold, + log_level=log_level, + short_output=short_output, ).assert_failed() @pytest.mark.parametrize( diff --git a/test/auto/utils.py b/test/auto/utils.py index d375f513..94730d9f 100644 --- a/test/auto/utils.py +++ b/test/auto/utils.py @@ -56,6 +56,7 @@ def modify_settings( max_depth: MaxDepth | None = None, ngrams_length: NgramsLength | None = None, show_progress: Flag | None = None, + short_output: Flag | None = None, reports_extension: ReportsExtension | None = None, language: Language | None = None, log_level: LogLevel | None = None, @@ -72,6 +73,7 @@ def create_opt(key: str, value: Any | None) -> list[str]: + create_opt("max-depth", max_depth) + create_opt("ngrams-length", ngrams_length) + create_opt("show_progress", show_progress) + + create_opt("short-output", short_output) + create_opt("reports_extension", reports_extension) + create_opt("language", language) + create_opt("log-level", log_level) diff --git a/test/unit/codeplag/test_config.py b/test/unit/codeplag/test_config.py index b42b93f5..92243eec 100644 --- a/test/unit/codeplag/test_config.py +++ b/test/unit/codeplag/test_config.py @@ -125,6 +125,7 @@ def test_read_default_settings_conf(settings_config: Settings | None): "ngrams_length": DEFAULT_NGRAMS_LENGTH, "reports": Path("/home/bukabyka/reports"), "show_progress": 0, + "short_output": 0, "reports_extension": DEFAULT_REPORT_EXTENSION, "language": DEFAULT_LANGUAGE, "log_level": DEFAULT_LOG_LEVEL, @@ -138,6 +139,7 @@ def test_read_default_settings_conf(settings_config: Settings | None): "ngrams_length": 5, "environment": "/home/bukabyka/.env", "show_progress": 1, + "short_output": 0, "reports_extension": "json", "language": "ru", "log_level": "error", @@ -149,6 +151,7 @@ def test_read_default_settings_conf(settings_config: Settings | None): "ngrams_length": 5, "environment": Path("/home/bukabyka/.env"), "show_progress": 1, + "short_output": 0, "reports_extension": "json", "language": "ru", "log_level": "error", @@ -163,6 +166,7 @@ def test_read_default_settings_conf(settings_config: Settings | None): "ngrams_length": DEFAULT_NGRAMS_LENGTH, "reports": Path("/home/bukabyka/reports"), "show_progress": 0, + "short_output": 0, "reports_extension": DEFAULT_REPORT_EXTENSION, "language": DEFAULT_LANGUAGE, "log_level": DEFAULT_LOG_LEVEL,