Skip to content

Commit

Permalink
feat+refactor(lang+cli+report): Adds support for generating sources r…
Browse files Browse the repository at this point in the history
…eports and support for the general way of getting translations.

- Adds support for the general way of getting translations with gettext;
- Adds some additional code checks with ruff;
- Moves CLI arguments check into argument parser;
- Adds support for generating source reports.
- Adds translations of the CLI help messages into Russian;
- Adds auto-tests for checking that the translation works;
- Adds auto-tests for checking creating reports with different translations.

Refs: #186.
  • Loading branch information
Artanias authored May 31, 2024
1 parent 2c3df47 commit 70051ce
Show file tree
Hide file tree
Showing 43 changed files with 1,716 additions and 336 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ src/codeplag/consts.py
docker/base_ubuntu2004.dockerfile
docker/test_ubuntu2004.dockerfile
docker/ubuntu2004.dockerfile

# Translation
locales/**/*.mo
16 changes: 11 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
UTIL_VERSION := 0.4.4
UTIL_VERSION := 0.4.5
UTIL_NAME := codeplag
PWD := $(shell pwd)

Expand Down Expand Up @@ -82,7 +82,7 @@ man: substitute-sources
--url "https://github.com/OSLL/code-plagiarism" \
--output man/$(UTIL_NAME).1

install: substitute-sources man
install: substitute-sources man translate-compile
python3 -m pip install --root=/$(DESTDIR) .

@echo "Cleaning unnecessary files after Cython compilation"
Expand All @@ -97,8 +97,11 @@ install: substitute-sources man
install -D -m 0666 /dev/null $(DESTDIR)/$(CODEPLAG_LOG_PATH)
install -D -d -m 0755 $(DESTDIR)/$(LIB_PATH)

install -D -m 0666 src/templates/report_ru.templ $(DESTDIR)/$(LIB_PATH)/report_ru.templ
install -D -m 0666 src/templates/report_en.templ $(DESTDIR)/$(LIB_PATH)/report_en.templ
install -D -m 0666 src/templates/general.templ $(DESTDIR)/$(LIB_PATH)/general.templ
install -D -m 0666 src/templates/sources.templ $(DESTDIR)/$(LIB_PATH)/sources.templ

cp --recursive locales/translations/ $(DESTDIR)/$(LIB_PATH)/
find "$(DESTDIR)/$(LIB_PATH)/translations/" -type f -name '*.po' -exec rm --force {} +

if [ ! -f $(DESTDIR)/$(CONFIG_PATH) ]; then \
install -D -d -m 0755 $(DESTDIR)/etc/$(UTIL_NAME); \
Expand Down Expand Up @@ -168,7 +171,9 @@ reinstall: uninstall install
todo-list: clean-all
@grep --color=auto -r -n 'TODO' ./* --exclude=Makefile --exclude-dir=docs

help:
help: help-general help-translate

help-general:
@echo "Usage:"
@echo " make [targets] [arguments]"
@echo
Expand Down Expand Up @@ -202,3 +207,4 @@ help:
.PHONY: all test man

include docker.mk
include locales/i18n.mk
2 changes: 2 additions & 0 deletions docker/test_ubuntu2004.dockerfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM @BASE_DOCKER_TAG@

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update
RUN apt-get install -y debhelper
RUN pip3 install pytest==7.4.0 pytest-mock==3.11.1 @PYTHON_BUILD_LIBS@
RUN mkdir -p @LOGS_PATH@
Expand All @@ -12,6 +13,7 @@ ADD src/ /usr/src/@UTIL_NAME@/src
ADD README.md /usr/src/@UTIL_NAME@/README.md
ADD LICENSE /usr/src/@UTIL_NAME@/LICENSE
ADD Makefile /usr/src/@UTIL_NAME@/Makefile
ADD locales/ /usr/src/@UTIL_NAME@/locales
ADD docker.mk /usr/src/@UTIL_NAME@/docker.mk
ADD debian/ /usr/src/@UTIL_NAME@/debian

Expand Down
1 change: 1 addition & 0 deletions docker/ubuntu2004.dockerfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ADD src/ /usr/src/@UTIL_NAME@/src
ADD README.md /usr/src/@UTIL_NAME@/README.md
ADD LICENSE /usr/src/@UTIL_NAME@/LICENSE
ADD Makefile /usr/src/@UTIL_NAME@/Makefile
ADD locales/i18n.mk /usr/src/@UTIL_NAME@/locales/i18n.mk
ADD docker.mk /usr/src/@UTIL_NAME@/docker.mk
ADD @DEBIAN_PACKAGES_PATH@ /usr/src/@UTIL_NAME@/@DEBIAN_PACKAGES_PATH@

Expand Down
1 change: 0 additions & 1 deletion docs/notebooks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ def plot_and_save_result(
mean_times.append(summ / count)

plt.figure(figsize=(12, 12), dpi=80)
# plt.plot(unique_count_lines, mean_times, label='Среднее')

if trend == "linear":
z = np.polyfit(unique_count_lines, mean_times, 1)
Expand Down
2 changes: 2 additions & 0 deletions locales/babel.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[python: src/**.py]
[jinja2: src/templates/*.templ]
296 changes: 296 additions & 0 deletions locales/codeplag.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
# Translations template for codeplag.
# Copyright (C) 2024 Codeplag Development Team
# This file is distributed under the same license as the codeplag project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2024.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: codeplag 0.4.5\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-05-22 23:10+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Artyom Semidolin\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.14.0\n"

#: src/codeplag/codeplagcli.py:44
msgid "You cannot specify the same value multiple times. You provided '{values}'."
msgstr ""

#: src/codeplag/codeplagcli.py:61
msgid "Directory '{path}' not found or not a directory."
msgstr ""

#: src/codeplag/codeplagcli.py:76
msgid "File '{path}' not found or not a file."
msgstr ""

#: src/codeplag/codeplagcli.py:88
msgid "Modifies and shows static settings of the '{util_name}' util."
msgstr ""

#: src/codeplag/codeplagcli.py:94
msgid "Settings commands of the '{util_name}' util."
msgstr ""

#: src/codeplag/codeplagcli.py:105
msgid "Manage the '{util_name}' util settings."
msgstr ""

#: src/codeplag/codeplagcli.py:112
msgid "Path to the environment file with GitHub access token."
msgstr ""

#: src/codeplag/codeplagcli.py:118
msgid "If defined, then saves reports about suspect works into provided path."
msgstr ""

#: src/codeplag/codeplagcli.py:127
msgid "Extension of saved report files."
msgstr ""

#: src/codeplag/codeplagcli.py:134
msgid "Show progress of searching plagiarism."
msgstr ""

#: src/codeplag/codeplagcli.py:141
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. "
"Otherwise, if this number is small, such as 50, then all work with "
"minimal similarity will be found."
msgstr ""

#: src/codeplag/codeplagcli.py:155
msgid "The language of help messages, generated reports, errors."
msgstr ""

#: src/codeplag/codeplagcli.py:162
msgid "The maximum number of processes that can be used to compare works."
msgstr ""

#: src/codeplag/codeplagcli.py:172
msgid "Show the '{util_name}' util settings."
msgstr ""

#: src/codeplag/codeplagcli.py:176
msgid "Start searching similar works."
msgstr ""

#: src/codeplag/codeplagcli.py:182
msgid "Absolute or relative path to a local directories with project files."
msgstr ""

#: src/codeplag/codeplagcli.py:194
msgid "Absolute or relative path to files on a computer."
msgstr ""

#: src/codeplag/codeplagcli.py:201
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:212
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:221
msgid "Ignore the threshold when checking of works."
msgstr ""

#: src/codeplag/codeplagcli.py:228
msgid "Extension responsible for the analyzed programming language."
msgstr ""

#: src/codeplag/codeplagcli.py:238
msgid "Searching in all branches."
msgstr ""

#: src/codeplag/codeplagcli.py:245
msgid "A regular expression to filter searching repositories on GitHub."
msgstr ""

#: src/codeplag/codeplagcli.py:252
msgid "URL to file in a GitHub repository."
msgstr ""

#: src/codeplag/codeplagcli.py:258
msgid "GitHub organization/user name."
msgstr ""

#: src/codeplag/codeplagcli.py:265
msgid "URL to a GitHub project folder."
msgstr ""

#: src/codeplag/codeplagcli.py:275
msgid ""
"Handling generated by the {util_name} reports as creating html report "
"file or show it on console."
msgstr ""

#: src/codeplag/codeplagcli.py:283
msgid "Report commands of the '{util_name}' util."
msgstr ""

#: src/codeplag/codeplagcli.py:294
msgid "Generate general report from created some time ago report files."
msgstr ""

#: src/codeplag/codeplagcli.py:299
msgid ""
"Path to save generated report. If it's a directory, then create a file in"
" it."
msgstr ""

#: src/codeplag/codeplagcli.py:309
msgid "Type of the created report file."
msgstr ""

#: src/codeplag/codeplagcli.py:319
msgid ""
"Program help to find similar parts of source codes for the different "
"languages."
msgstr ""

#: src/codeplag/codeplagcli.py:327
msgid "Print current version number and exit."
msgstr ""

#: src/codeplag/codeplagcli.py:333
msgid "Show debug messages."
msgstr ""

#: src/codeplag/codeplagcli.py:338
msgid "Commands help."
msgstr ""

#: src/codeplag/codeplagcli.py:354
msgid "No command is provided; please choose one from the available (--help)."
msgstr ""

#: src/codeplag/codeplagcli.py:369
msgid "There is nothing to modify; please provide at least one argument."
msgstr ""

#: src/codeplag/codeplagcli.py:374
msgid "The'repo-regexp' option requires the provided 'github-user' option."
msgstr ""

#: src/codeplag/codeplagcli.py:384
msgid ""
"The'path-regexp' option requires the provided 'directories', 'github-"
"user', or 'github-project-folder' options."
msgstr ""

#: src/templates/general.templ:5 src/templates/sources.templ:5
msgid "Comparative report"
msgstr ""

#: src/templates/general.templ:40
msgid "Check results"
msgstr ""

#: src/templates/general.templ:44 src/templates/sources.templ:45
msgid "General information"
msgstr ""

#: src/templates/general.templ:46
msgid "Path"
msgstr ""

#: src/templates/general.templ:47
msgid "Last modification date"
msgstr ""

#: src/templates/general.templ:48
msgid "Check date"
msgstr ""

#: src/templates/general.templ:61
msgid "Metrics information"
msgstr ""

#: src/templates/general.templ:63
msgid "Metric"
msgstr ""

#: src/templates/general.templ:64
msgid "Value"
msgstr ""

#: src/templates/general.templ:67
msgid "Jaccard Coefficient"
msgstr ""

#: src/templates/general.templ:71
msgid "Similarity of operators"
msgstr ""

#: src/templates/general.templ:75
msgid "Similarity of keywords"
msgstr ""

#: src/templates/general.templ:79
msgid "Similarity of literals"
msgstr ""

#: src/templates/general.templ:82
msgid "Weighted average by fast metrics"
msgstr ""

#: src/templates/general.templ:85
msgid "Similarity of structures"
msgstr ""

#: src/templates/general.templ:91
msgid "Similar parts of the second program relative to the first"
msgstr ""

#: src/templates/general.templ:93 src/templates/general.templ:125
msgid "Part of the first program"
msgstr ""

#: src/templates/general.templ:94 src/templates/general.templ:124
msgid "Part of the second program"
msgstr ""

#: src/templates/general.templ:95 src/templates/general.templ:126
#: src/templates/sources.templ:60
msgid "Similarity"
msgstr ""

#: src/templates/general.templ:122
msgid "Similar parts of the first program relative to the second"
msgstr ""

#: src/templates/sources.templ:41
msgid "Verification results"
msgstr ""

#: src/templates/sources.templ:47
msgid "The path to the file being checked"
msgstr ""

#: src/templates/sources.templ:55
msgid "Similar parts of the programs"
msgstr ""

#: src/templates/sources.templ:57
msgid "The name of a similar file"
msgstr ""

#: src/templates/sources.templ:58
msgid "Part of the file that is being checked"
msgstr ""

#: src/templates/sources.templ:59
msgid "Part of a similar file"
msgstr ""

Loading

0 comments on commit 70051ce

Please sign in to comment.