diff --git a/.coverage b/.coverage
new file mode 100644
index 0000000..a16cae0
Binary files /dev/null and b/.coverage differ
diff --git a/.gitignore b/.gitignore
index 9a9dad1..96c5733 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,19 +37,19 @@ pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
-htmlcov/
-.tox/
-.nox/
-.coverage
-.coverage.*
-.cache
-nosetests.xml
-coverage.xml
-*.cover
-*.py,cover
-.hypothesis/
-.pytest_cache/
-cover/
+#htmlcov/
+#.tox/
+#.nox/
+#.coverage
+#.coverage.*
+#.cache
+#nosetests.xml
+#coverage.xml
+#*.cover
+#*.py,cover
+#.hypothesis/
+#.pytest_cache/
+#cover/
# Translations
*.mo
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..dd9bb19
--- /dev/null
+++ b/README.md
@@ -0,0 +1,173 @@
+# Проект домашнего задания на SkyEng
+## Описание:
+Проект домашнего задания по созданию виджета для работы с банковскими картами.
+
+## Установка:
+
+1. Клонируйте репозиторий:
+ [ссылка](https://github.com/kostya261/PythonProject/pull/3)
+
+3. Зависимости указанные в файле: *pyproject.toml*
+```
+[tool.poetry.dependencies]
+python = "^3.13"
+poetry-core = "^2.1.3"
+shell = "^1.0.1"
+
+[tool.poetry.group.dev.dependencies]
+requests = "^2.32.3"
+pytest = "^8.3.5"
+pytest-cov = "^6.1.1"
+
+[tool.poetry.group.lint.dependencies]
+flake8 = "^7.2.0"
+mypy = "^1.15.0"
+black = "^25.1.0"
+isort = "^6.0.1"
+```
+
+## Использование:
+
+Откройте проект например в PyCharm, найдите PythonPackage\test, откройте файл main.py и запустите его.
+По желанию можно его всячески модифицировать в рамках тестирования написанных функций.
+
+В PythonPackage\src описаны три модуля:
+**masks.py, widget.py, processing.py**, которые и реализуют весь скромный функционал домашнего задания.
+
+### masks.py
+В модуле masks.py описаны функции *get_mask_card_number* и *get_mask_account*
+обе функции выполняют маскировку реквизитов:
+
+*get_mask_card_number* - маскирует номера карт
+Принимает на входе строку с номером карты.
+На выходе строка с маскированым номером
+
+*get_mask_account* - маскирует номер счёта
+Принимает на входе строку с номером счёта.
+На выходе строка с маскированым номером
+
+Примеры использования:
+```
+temp_result = get_mask_card_number("4365592421228764")
+print(temp_result)
+```
+Результат:
+```
+4365 59** **** 8764
+```
+
+```
+temp_result = get_mask_account("12345678910111213145")
+print(temp_result)
+```
+
+Результат:
+```
+**3145
+```
+
+### widget.py
+В данном модуле описаны функции:
+
+*mask_account_ card* - которая принимает на вход строку с наименованием карты и её номером после чего определяет что это за карта
+и вызывает необходимую функцию из модуля masks.py и возвращает строку с маскированным номером карты
+
+*get_date* - конвертирует строку формата **"2024-03-11T02:26:18.671407"** в строку где указана дата в формате **ДД.ММ.ГГГ**
+
+Пример использования:
+```
+print(mask_account_card("Счет 73654108430535874307"))
+print(mask_account_card("Visa Platinum 7000712289606361"))
+print(mask_account_card("Maestro 7000792108106361"))
+```
+
+Результат:
+```
+Счет **4307
+Visa Platinum 7000 71** **** 6361
+Maestro 7000 79** **** 6361
+```
+
+```
+print(get_date("2024-03-11T02:26:18.671407"))
+```
+
+Результат:
+```
+11.03.2024
+```
+
+
+### proctssing.py
+proctssing.py так же содержит две функции как и предыдущие модули:
+
+*filter_by_state* - Функция возвращает новый список словарей, содержащий только те словари, у которых
+ключ state соответствует указанному значению.
+
+Принимает на входе два параметра:
+*список с данными карт
+*строка с параметром state по которому происходит отбор карт в новый список
+
+На выходе функции новый список с отобранными по заданному параметру картами
+
+
+*sort_by_date* - Функция возвращает новый список, отсортированный по дате (date)
+
+Принимает на входе два параметра:
+*список с данными карт
+*Булевое значение которое указывает тип сортировки (возрастающи/ убывающий)
+
+На выходе функции новый список с отсортированными по дате значениями.
+
+Пример использования:
+```
+print(
+ "state ",
+ filter_by_state(
+ [
+ {"id": 41428829, "state": "EXECUTED", "date": "2019-07-03T18:35:29.512364"},
+ {"id": 939719570, "state": "EXECUTED", "date": "2018-06-30T02:08:58.425572"},
+ {"id": 594226727, "state": "CANCELED", "date": "2018-09-12T21:27:25.241689"},
+ {"id": 615064591, "state": "CANCELED", "date": "2018-10-14T08:21:33.419441"},
+ ]
+ ),
+ )
+
+print(
+ "sort ",
+ sort_by_date(
+ [
+ {"id": 41428829, "state": "EXECUTED", "date": "2019-07-03T18:35:29.512364"},
+ {"id": 939719570, "state": "EXECUTED", "date": "2018-06-30T02:08:58.425572"},
+ {"id": 594226727, "state": "CANCELED", "date": "2018-09-12T21:27:25.241689"},
+ {"id": 615064591, "state": "CANCELED", "date": "2018-10-14T08:21:33.419441"},
+ ],
+ True,
+ ),
+ )
+```
+
+Результат:
+```
+state [{'id': 41428829, 'state': 'EXECUTED', 'date': '2019-07-03T18:35:29.512364'}, {'id': 939719570, 'state': 'EXECUTED', 'date': '2018-06-30T02:08:58.425572'}]
+sort [{'id': 41428829, 'state': 'EXECUTED', 'date': '2019-07-03T18:35:29.512364'}, {'id': 615064591, 'state': 'CANCELED', 'date': '2018-10-14T08:21:33.419441'},
+{'id': 594226727, 'state': 'CANCELED', 'date': '2018-09-12T21:27:25.241689'}, {'id': 939719570, 'state': 'EXECUTED', 'date': '2018-06-30T02:08:58.425572'}]
+```
+
+## Тесты
+Добавлены тестовые файлы test_widget.py, test_masks.pym test_processing.py
+которые проверяют ранее написанные функции.
+В них реализованы функции:
+1. test_mask_account_card,
+2. test_mask_account_card_parametrize,
+3. test_get_date,
+4. test_filter_by_state,
+5. test_sort_by_date,
+6. test_get_mask_card_number,
+7. test_get_mask_account
+
+Тест запускается из командной строки, командой **pytest**
+
+## Лицензия:
+
+В данном конкретном случае вероятно её ещё нет 8-/
diff --git a/htmlcov/class_index.html b/htmlcov/class_index.html
new file mode 100644
index 0000000..49b84d7
--- /dev/null
+++ b/htmlcov/class_index.html
@@ -0,0 +1,139 @@
+
+
+
+
+ Coverage report
+
+
+
+
+
+
+
+
+
+ No items found using the specified filter.
+
+
+
+
+
diff --git a/htmlcov/coverage_html_cb_497bf287.js b/htmlcov/coverage_html_cb_497bf287.js
new file mode 100644
index 0000000..1face13
--- /dev/null
+++ b/htmlcov/coverage_html_cb_497bf287.js
@@ -0,0 +1,733 @@
+// Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
+// For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt
+
+// Coverage.py HTML report browser code.
+/*jslint browser: true, sloppy: true, vars: true, plusplus: true, maxerr: 50, indent: 4 */
+/*global coverage: true, document, window, $ */
+
+coverage = {};
+
+// General helpers
+function debounce(callback, wait) {
+ let timeoutId = null;
+ return function(...args) {
+ clearTimeout(timeoutId);
+ timeoutId = setTimeout(() => {
+ callback.apply(this, args);
+ }, wait);
+ };
+};
+
+function checkVisible(element) {
+ const rect = element.getBoundingClientRect();
+ const viewBottom = Math.max(document.documentElement.clientHeight, window.innerHeight);
+ const viewTop = 30;
+ return !(rect.bottom < viewTop || rect.top >= viewBottom);
+}
+
+function on_click(sel, fn) {
+ const elt = document.querySelector(sel);
+ if (elt) {
+ elt.addEventListener("click", fn);
+ }
+}
+
+// Helpers for table sorting
+function getCellValue(row, column = 0) {
+ const cell = row.cells[column] // nosemgrep: eslint.detect-object-injection
+ if (cell.childElementCount == 1) {
+ var child = cell.firstElementChild;
+ if (child.tagName === "A") {
+ child = child.firstElementChild;
+ }
+ if (child instanceof HTMLDataElement && child.value) {
+ return child.value;
+ }
+ }
+ return cell.innerText || cell.textContent;
+}
+
+function rowComparator(rowA, rowB, column = 0) {
+ let valueA = getCellValue(rowA, column);
+ let valueB = getCellValue(rowB, column);
+ if (!isNaN(valueA) && !isNaN(valueB)) {
+ return valueA - valueB;
+ }
+ return valueA.localeCompare(valueB, undefined, {numeric: true});
+}
+
+function sortColumn(th) {
+ // Get the current sorting direction of the selected header,
+ // clear state on other headers and then set the new sorting direction.
+ const currentSortOrder = th.getAttribute("aria-sort");
+ [...th.parentElement.cells].forEach(header => header.setAttribute("aria-sort", "none"));
+ var direction;
+ if (currentSortOrder === "none") {
+ direction = th.dataset.defaultSortOrder || "ascending";
+ }
+ else if (currentSortOrder === "ascending") {
+ direction = "descending";
+ }
+ else {
+ direction = "ascending";
+ }
+ th.setAttribute("aria-sort", direction);
+
+ const column = [...th.parentElement.cells].indexOf(th)
+
+ // Sort all rows and afterwards append them in order to move them in the DOM.
+ Array.from(th.closest("table").querySelectorAll("tbody tr"))
+ .sort((rowA, rowB) => rowComparator(rowA, rowB, column) * (direction === "ascending" ? 1 : -1))
+ .forEach(tr => tr.parentElement.appendChild(tr));
+
+ // Save the sort order for next time.
+ if (th.id !== "region") {
+ let th_id = "file"; // Sort by file if we don't have a column id
+ let current_direction = direction;
+ const stored_list = localStorage.getItem(coverage.INDEX_SORT_STORAGE);
+ if (stored_list) {
+ ({th_id, direction} = JSON.parse(stored_list))
+ }
+ localStorage.setItem(coverage.INDEX_SORT_STORAGE, JSON.stringify({
+ "th_id": th.id,
+ "direction": current_direction
+ }));
+ if (th.id !== th_id || document.getElementById("region")) {
+ // Sort column has changed, unset sorting by function or class.
+ localStorage.setItem(coverage.SORTED_BY_REGION, JSON.stringify({
+ "by_region": false,
+ "region_direction": current_direction
+ }));
+ }
+ }
+ else {
+ // Sort column has changed to by function or class, remember that.
+ localStorage.setItem(coverage.SORTED_BY_REGION, JSON.stringify({
+ "by_region": true,
+ "region_direction": direction
+ }));
+ }
+}
+
+// Find all the elements with data-shortcut attribute, and use them to assign a shortcut key.
+coverage.assign_shortkeys = function () {
+ document.querySelectorAll("[data-shortcut]").forEach(element => {
+ document.addEventListener("keypress", event => {
+ if (event.target.tagName.toLowerCase() === "input") {
+ return; // ignore keypress from search filter
+ }
+ if (event.key === element.dataset.shortcut) {
+ element.click();
+ }
+ });
+ });
+};
+
+// Create the events for the filter box.
+coverage.wire_up_filter = function () {
+ // Populate the filter and hide100 inputs if there are saved values for them.
+ const saved_filter_value = localStorage.getItem(coverage.FILTER_STORAGE);
+ if (saved_filter_value) {
+ document.getElementById("filter").value = saved_filter_value;
+ }
+ const saved_hide100_value = localStorage.getItem(coverage.HIDE100_STORAGE);
+ if (saved_hide100_value) {
+ document.getElementById("hide100").checked = JSON.parse(saved_hide100_value);
+ }
+
+ // Cache elements.
+ const table = document.querySelector("table.index");
+ const table_body_rows = table.querySelectorAll("tbody tr");
+ const no_rows = document.getElementById("no_rows");
+
+ // Observe filter keyevents.
+ const filter_handler = (event => {
+ // Keep running total of each metric, first index contains number of shown rows
+ const totals = new Array(table.rows[0].cells.length).fill(0);
+ // Accumulate the percentage as fraction
+ totals[totals.length - 1] = { "numer": 0, "denom": 0 }; // nosemgrep: eslint.detect-object-injection
+
+ var text = document.getElementById("filter").value;
+ // Store filter value
+ localStorage.setItem(coverage.FILTER_STORAGE, text);
+ const casefold = (text === text.toLowerCase());
+ const hide100 = document.getElementById("hide100").checked;
+ // Store hide value.
+ localStorage.setItem(coverage.HIDE100_STORAGE, JSON.stringify(hide100));
+
+ // Hide / show elements.
+ table_body_rows.forEach(row => {
+ var show = false;
+ // Check the text filter.
+ for (let column = 0; column < totals.length; column++) {
+ cell = row.cells[column];
+ if (cell.classList.contains("name")) {
+ var celltext = cell.textContent;
+ if (casefold) {
+ celltext = celltext.toLowerCase();
+ }
+ if (celltext.includes(text)) {
+ show = true;
+ }
+ }
+ }
+
+ // Check the "hide covered" filter.
+ if (show && hide100) {
+ const [numer, denom] = row.cells[row.cells.length - 1].dataset.ratio.split(" ");
+ show = (numer !== denom);
+ }
+
+ if (!show) {
+ // hide
+ row.classList.add("hidden");
+ return;
+ }
+
+ // show
+ row.classList.remove("hidden");
+ totals[0]++;
+
+ for (let column = 0; column < totals.length; column++) {
+ // Accumulate dynamic totals
+ cell = row.cells[column] // nosemgrep: eslint.detect-object-injection
+ if (cell.classList.contains("name")) {
+ continue;
+ }
+ if (column === totals.length - 1) {
+ // Last column contains percentage
+ const [numer, denom] = cell.dataset.ratio.split(" ");
+ totals[column]["numer"] += parseInt(numer, 10); // nosemgrep: eslint.detect-object-injection
+ totals[column]["denom"] += parseInt(denom, 10); // nosemgrep: eslint.detect-object-injection
+ }
+ else {
+ totals[column] += parseInt(cell.textContent, 10); // nosemgrep: eslint.detect-object-injection
+ }
+ }
+ });
+
+ // Show placeholder if no rows will be displayed.
+ if (!totals[0]) {
+ // Show placeholder, hide table.
+ no_rows.style.display = "block";
+ table.style.display = "none";
+ return;
+ }
+
+ // Hide placeholder, show table.
+ no_rows.style.display = null;
+ table.style.display = null;
+
+ const footer = table.tFoot.rows[0];
+ // Calculate new dynamic sum values based on visible rows.
+ for (let column = 0; column < totals.length; column++) {
+ // Get footer cell element.
+ const cell = footer.cells[column]; // nosemgrep: eslint.detect-object-injection
+ if (cell.classList.contains("name")) {
+ continue;
+ }
+
+ // Set value into dynamic footer cell element.
+ if (column === totals.length - 1) {
+ // Percentage column uses the numerator and denominator,
+ // and adapts to the number of decimal places.
+ const match = /\.([0-9]+)/.exec(cell.textContent);
+ const places = match ? match[1].length : 0;
+ const { numer, denom } = totals[column]; // nosemgrep: eslint.detect-object-injection
+ cell.dataset.ratio = `${numer} ${denom}`;
+ // Check denom to prevent NaN if filtered files contain no statements
+ cell.textContent = denom
+ ? `${(numer * 100 / denom).toFixed(places)}%`
+ : `${(100).toFixed(places)}%`;
+ }
+ else {
+ cell.textContent = totals[column]; // nosemgrep: eslint.detect-object-injection
+ }
+ }
+ });
+
+ document.getElementById("filter").addEventListener("input", debounce(filter_handler));
+ document.getElementById("hide100").addEventListener("input", debounce(filter_handler));
+
+ // Trigger change event on setup, to force filter on page refresh
+ // (filter value may still be present).
+ document.getElementById("filter").dispatchEvent(new Event("input"));
+ document.getElementById("hide100").dispatchEvent(new Event("input"));
+};
+coverage.FILTER_STORAGE = "COVERAGE_FILTER_VALUE";
+coverage.HIDE100_STORAGE = "COVERAGE_HIDE100_VALUE";
+
+// Set up the click-to-sort columns.
+coverage.wire_up_sorting = function () {
+ document.querySelectorAll("[data-sortable] th[aria-sort]").forEach(
+ th => th.addEventListener("click", e => sortColumn(e.target))
+ );
+
+ // Look for a localStorage item containing previous sort settings:
+ let th_id = "file", direction = "ascending";
+ const stored_list = localStorage.getItem(coverage.INDEX_SORT_STORAGE);
+ if (stored_list) {
+ ({th_id, direction} = JSON.parse(stored_list));
+ }
+ let by_region = false, region_direction = "ascending";
+ const sorted_by_region = localStorage.getItem(coverage.SORTED_BY_REGION);
+ if (sorted_by_region) {
+ ({
+ by_region,
+ region_direction
+ } = JSON.parse(sorted_by_region));
+ }
+
+ const region_id = "region";
+ if (by_region && document.getElementById(region_id)) {
+ direction = region_direction;
+ }
+ // If we are in a page that has a column with id of "region", sort on
+ // it if the last sort was by function or class.
+ let th;
+ if (document.getElementById(region_id)) {
+ th = document.getElementById(by_region ? region_id : th_id);
+ }
+ else {
+ th = document.getElementById(th_id);
+ }
+ th.setAttribute("aria-sort", direction === "ascending" ? "descending" : "ascending");
+ th.click()
+};
+
+coverage.INDEX_SORT_STORAGE = "COVERAGE_INDEX_SORT_2";
+coverage.SORTED_BY_REGION = "COVERAGE_SORT_REGION";
+
+// Loaded on index.html
+coverage.index_ready = function () {
+ coverage.assign_shortkeys();
+ coverage.wire_up_filter();
+ coverage.wire_up_sorting();
+
+ on_click(".button_prev_file", coverage.to_prev_file);
+ on_click(".button_next_file", coverage.to_next_file);
+
+ on_click(".button_show_hide_help", coverage.show_hide_help);
+};
+
+// -- pyfile stuff --
+
+coverage.LINE_FILTERS_STORAGE = "COVERAGE_LINE_FILTERS";
+
+coverage.pyfile_ready = function () {
+ // If we're directed to a particular line number, highlight the line.
+ var frag = location.hash;
+ if (frag.length > 2 && frag[1] === "t") {
+ document.querySelector(frag).closest(".n").classList.add("highlight");
+ coverage.set_sel(parseInt(frag.substr(2), 10));
+ }
+ else {
+ coverage.set_sel(0);
+ }
+
+ on_click(".button_toggle_run", coverage.toggle_lines);
+ on_click(".button_toggle_mis", coverage.toggle_lines);
+ on_click(".button_toggle_exc", coverage.toggle_lines);
+ on_click(".button_toggle_par", coverage.toggle_lines);
+
+ on_click(".button_next_chunk", coverage.to_next_chunk_nicely);
+ on_click(".button_prev_chunk", coverage.to_prev_chunk_nicely);
+ on_click(".button_top_of_page", coverage.to_top);
+ on_click(".button_first_chunk", coverage.to_first_chunk);
+
+ on_click(".button_prev_file", coverage.to_prev_file);
+ on_click(".button_next_file", coverage.to_next_file);
+ on_click(".button_to_index", coverage.to_index);
+
+ on_click(".button_show_hide_help", coverage.show_hide_help);
+
+ coverage.filters = undefined;
+ try {
+ coverage.filters = localStorage.getItem(coverage.LINE_FILTERS_STORAGE);
+ } catch(err) {}
+
+ if (coverage.filters) {
+ coverage.filters = JSON.parse(coverage.filters);
+ }
+ else {
+ coverage.filters = {run: false, exc: true, mis: true, par: true};
+ }
+
+ for (cls in coverage.filters) {
+ coverage.set_line_visibilty(cls, coverage.filters[cls]); // nosemgrep: eslint.detect-object-injection
+ }
+
+ coverage.assign_shortkeys();
+ coverage.init_scroll_markers();
+ coverage.wire_up_sticky_header();
+
+ document.querySelectorAll("[id^=ctxs]").forEach(
+ cbox => cbox.addEventListener("click", coverage.expand_contexts)
+ );
+
+ // Rebuild scroll markers when the window height changes.
+ window.addEventListener("resize", coverage.build_scroll_markers);
+};
+
+coverage.toggle_lines = function (event) {
+ const btn = event.target.closest("button");
+ const category = btn.value
+ const show = !btn.classList.contains("show_" + category);
+ coverage.set_line_visibilty(category, show);
+ coverage.build_scroll_markers();
+ coverage.filters[category] = show;
+ try {
+ localStorage.setItem(coverage.LINE_FILTERS_STORAGE, JSON.stringify(coverage.filters));
+ } catch(err) {}
+};
+
+coverage.set_line_visibilty = function (category, should_show) {
+ const cls = "show_" + category;
+ const btn = document.querySelector(".button_toggle_" + category);
+ if (btn) {
+ if (should_show) {
+ document.querySelectorAll("#source ." + category).forEach(e => e.classList.add(cls));
+ btn.classList.add(cls);
+ }
+ else {
+ document.querySelectorAll("#source ." + category).forEach(e => e.classList.remove(cls));
+ btn.classList.remove(cls);
+ }
+ }
+};
+
+// Return the nth line div.
+coverage.line_elt = function (n) {
+ return document.getElementById("t" + n)?.closest("p");
+};
+
+// Set the selection. b and e are line numbers.
+coverage.set_sel = function (b, e) {
+ // The first line selected.
+ coverage.sel_begin = b;
+ // The next line not selected.
+ coverage.sel_end = (e === undefined) ? b+1 : e;
+};
+
+coverage.to_top = function () {
+ coverage.set_sel(0, 1);
+ coverage.scroll_window(0);
+};
+
+coverage.to_first_chunk = function () {
+ coverage.set_sel(0, 1);
+ coverage.to_next_chunk();
+};
+
+coverage.to_prev_file = function () {
+ window.location = document.getElementById("prevFileLink").href;
+}
+
+coverage.to_next_file = function () {
+ window.location = document.getElementById("nextFileLink").href;
+}
+
+coverage.to_index = function () {
+ location.href = document.getElementById("indexLink").href;
+}
+
+coverage.show_hide_help = function () {
+ const helpCheck = document.getElementById("help_panel_state")
+ helpCheck.checked = !helpCheck.checked;
+}
+
+// Return a string indicating what kind of chunk this line belongs to,
+// or null if not a chunk.
+coverage.chunk_indicator = function (line_elt) {
+ const classes = line_elt?.className;
+ if (!classes) {
+ return null;
+ }
+ const match = classes.match(/\bshow_\w+\b/);
+ if (!match) {
+ return null;
+ }
+ return match[0];
+};
+
+coverage.to_next_chunk = function () {
+ const c = coverage;
+
+ // Find the start of the next colored chunk.
+ var probe = c.sel_end;
+ var chunk_indicator, probe_line;
+ while (true) {
+ probe_line = c.line_elt(probe);
+ if (!probe_line) {
+ return;
+ }
+ chunk_indicator = c.chunk_indicator(probe_line);
+ if (chunk_indicator) {
+ break;
+ }
+ probe++;
+ }
+
+ // There's a next chunk, `probe` points to it.
+ var begin = probe;
+
+ // Find the end of this chunk.
+ var next_indicator = chunk_indicator;
+ while (next_indicator === chunk_indicator) {
+ probe++;
+ probe_line = c.line_elt(probe);
+ next_indicator = c.chunk_indicator(probe_line);
+ }
+ c.set_sel(begin, probe);
+ c.show_selection();
+};
+
+coverage.to_prev_chunk = function () {
+ const c = coverage;
+
+ // Find the end of the prev colored chunk.
+ var probe = c.sel_begin-1;
+ var probe_line = c.line_elt(probe);
+ if (!probe_line) {
+ return;
+ }
+ var chunk_indicator = c.chunk_indicator(probe_line);
+ while (probe > 1 && !chunk_indicator) {
+ probe--;
+ probe_line = c.line_elt(probe);
+ if (!probe_line) {
+ return;
+ }
+ chunk_indicator = c.chunk_indicator(probe_line);
+ }
+
+ // There's a prev chunk, `probe` points to its last line.
+ var end = probe+1;
+
+ // Find the beginning of this chunk.
+ var prev_indicator = chunk_indicator;
+ while (prev_indicator === chunk_indicator) {
+ probe--;
+ if (probe <= 0) {
+ return;
+ }
+ probe_line = c.line_elt(probe);
+ prev_indicator = c.chunk_indicator(probe_line);
+ }
+ c.set_sel(probe+1, end);
+ c.show_selection();
+};
+
+// Returns 0, 1, or 2: how many of the two ends of the selection are on
+// the screen right now?
+coverage.selection_ends_on_screen = function () {
+ if (coverage.sel_begin === 0) {
+ return 0;
+ }
+
+ const begin = coverage.line_elt(coverage.sel_begin);
+ const end = coverage.line_elt(coverage.sel_end-1);
+
+ return (
+ (checkVisible(begin) ? 1 : 0)
+ + (checkVisible(end) ? 1 : 0)
+ );
+};
+
+coverage.to_next_chunk_nicely = function () {
+ if (coverage.selection_ends_on_screen() === 0) {
+ // The selection is entirely off the screen:
+ // Set the top line on the screen as selection.
+
+ // This will select the top-left of the viewport
+ // As this is most likely the span with the line number we take the parent
+ const line = document.elementFromPoint(0, 0).parentElement;
+ if (line.parentElement !== document.getElementById("source")) {
+ // The element is not a source line but the header or similar
+ coverage.select_line_or_chunk(1);
+ }
+ else {
+ // We extract the line number from the id
+ coverage.select_line_or_chunk(parseInt(line.id.substring(1), 10));
+ }
+ }
+ coverage.to_next_chunk();
+};
+
+coverage.to_prev_chunk_nicely = function () {
+ if (coverage.selection_ends_on_screen() === 0) {
+ // The selection is entirely off the screen:
+ // Set the lowest line on the screen as selection.
+
+ // This will select the bottom-left of the viewport
+ // As this is most likely the span with the line number we take the parent
+ const line = document.elementFromPoint(document.documentElement.clientHeight-1, 0).parentElement;
+ if (line.parentElement !== document.getElementById("source")) {
+ // The element is not a source line but the header or similar
+ coverage.select_line_or_chunk(coverage.lines_len);
+ }
+ else {
+ // We extract the line number from the id
+ coverage.select_line_or_chunk(parseInt(line.id.substring(1), 10));
+ }
+ }
+ coverage.to_prev_chunk();
+};
+
+// Select line number lineno, or if it is in a colored chunk, select the
+// entire chunk
+coverage.select_line_or_chunk = function (lineno) {
+ var c = coverage;
+ var probe_line = c.line_elt(lineno);
+ if (!probe_line) {
+ return;
+ }
+ var the_indicator = c.chunk_indicator(probe_line);
+ if (the_indicator) {
+ // The line is in a highlighted chunk.
+ // Search backward for the first line.
+ var probe = lineno;
+ var indicator = the_indicator;
+ while (probe > 0 && indicator === the_indicator) {
+ probe--;
+ probe_line = c.line_elt(probe);
+ if (!probe_line) {
+ break;
+ }
+ indicator = c.chunk_indicator(probe_line);
+ }
+ var begin = probe + 1;
+
+ // Search forward for the last line.
+ probe = lineno;
+ indicator = the_indicator;
+ while (indicator === the_indicator) {
+ probe++;
+ probe_line = c.line_elt(probe);
+ indicator = c.chunk_indicator(probe_line);
+ }
+
+ coverage.set_sel(begin, probe);
+ }
+ else {
+ coverage.set_sel(lineno);
+ }
+};
+
+coverage.show_selection = function () {
+ // Highlight the lines in the chunk
+ document.querySelectorAll("#source .highlight").forEach(e => e.classList.remove("highlight"));
+ for (let probe = coverage.sel_begin; probe < coverage.sel_end; probe++) {
+ coverage.line_elt(probe).querySelector(".n").classList.add("highlight");
+ }
+
+ coverage.scroll_to_selection();
+};
+
+coverage.scroll_to_selection = function () {
+ // Scroll the page if the chunk isn't fully visible.
+ if (coverage.selection_ends_on_screen() < 2) {
+ const element = coverage.line_elt(coverage.sel_begin);
+ coverage.scroll_window(element.offsetTop - 60);
+ }
+};
+
+coverage.scroll_window = function (to_pos) {
+ window.scroll({top: to_pos, behavior: "smooth"});
+};
+
+coverage.init_scroll_markers = function () {
+ // Init some variables
+ coverage.lines_len = document.querySelectorAll("#source > p").length;
+
+ // Build html
+ coverage.build_scroll_markers();
+};
+
+coverage.build_scroll_markers = function () {
+ const temp_scroll_marker = document.getElementById("scroll_marker")
+ if (temp_scroll_marker) temp_scroll_marker.remove();
+ // Don't build markers if the window has no scroll bar.
+ if (document.body.scrollHeight <= window.innerHeight) {
+ return;
+ }
+
+ const marker_scale = window.innerHeight / document.body.scrollHeight;
+ const line_height = Math.min(Math.max(3, window.innerHeight / coverage.lines_len), 10);
+
+ let previous_line = -99, last_mark, last_top;
+
+ const scroll_marker = document.createElement("div");
+ scroll_marker.id = "scroll_marker";
+ document.getElementById("source").querySelectorAll(
+ "p.show_run, p.show_mis, p.show_exc, p.show_exc, p.show_par"
+ ).forEach(element => {
+ const line_top = Math.floor(element.offsetTop * marker_scale);
+ const line_number = parseInt(element.querySelector(".n a").id.substr(1));
+
+ if (line_number === previous_line + 1) {
+ // If this solid missed block just make previous mark higher.
+ last_mark.style.height = `${line_top + line_height - last_top}px`;
+ }
+ else {
+ // Add colored line in scroll_marker block.
+ last_mark = document.createElement("div");
+ last_mark.id = `m${line_number}`;
+ last_mark.classList.add("marker");
+ last_mark.style.height = `${line_height}px`;
+ last_mark.style.top = `${line_top}px`;
+ scroll_marker.append(last_mark);
+ last_top = line_top;
+ }
+
+ previous_line = line_number;
+ });
+
+ // Append last to prevent layout calculation
+ document.body.append(scroll_marker);
+};
+
+coverage.wire_up_sticky_header = function () {
+ const header = document.querySelector("header");
+ const header_bottom = (
+ header.querySelector(".content h2").getBoundingClientRect().top -
+ header.getBoundingClientRect().top
+ );
+
+ function updateHeader() {
+ if (window.scrollY > header_bottom) {
+ header.classList.add("sticky");
+ }
+ else {
+ header.classList.remove("sticky");
+ }
+ }
+
+ window.addEventListener("scroll", updateHeader);
+ updateHeader();
+};
+
+coverage.expand_contexts = function (e) {
+ var ctxs = e.target.parentNode.querySelector(".ctxs");
+
+ if (!ctxs.classList.contains("expanded")) {
+ var ctxs_text = ctxs.textContent;
+ var width = Number(ctxs_text[0]);
+ ctxs.textContent = "";
+ for (var i = 1; i < ctxs_text.length; i += width) {
+ key = ctxs_text.substring(i, i + width).trim();
+ ctxs.appendChild(document.createTextNode(contexts[key]));
+ ctxs.appendChild(document.createElement("br"));
+ }
+ ctxs.classList.add("expanded");
+ }
+};
+
+document.addEventListener("DOMContentLoaded", () => {
+ if (document.body.classList.contains("indexfile")) {
+ coverage.index_ready();
+ }
+ else {
+ coverage.pyfile_ready();
+ }
+});
diff --git a/htmlcov/favicon_32_cb_58284776.png b/htmlcov/favicon_32_cb_58284776.png
new file mode 100644
index 0000000..8649f04
Binary files /dev/null and b/htmlcov/favicon_32_cb_58284776.png differ
diff --git a/htmlcov/function_index.html b/htmlcov/function_index.html
new file mode 100644
index 0000000..bd05825
--- /dev/null
+++ b/htmlcov/function_index.html
@@ -0,0 +1,187 @@
+
+
+
+
+ Coverage report
+
+
+
+
+
+
+
+
+
+ No items found using the specified filter.
+
+
+
+
+
diff --git a/htmlcov/index.html b/htmlcov/index.html
new file mode 100644
index 0000000..bda77f0
--- /dev/null
+++ b/htmlcov/index.html
@@ -0,0 +1,132 @@
+
+
+
+
+ Coverage report
+
+
+
+
+
+
+
+
+
+ No items found using the specified filter.
+
+
+
+
+
diff --git a/htmlcov/keybd_closed_cb_ce680311.png b/htmlcov/keybd_closed_cb_ce680311.png
new file mode 100644
index 0000000..ba119c4
Binary files /dev/null and b/htmlcov/keybd_closed_cb_ce680311.png differ
diff --git a/htmlcov/status.json b/htmlcov/status.json
new file mode 100644
index 0000000..73b842f
--- /dev/null
+++ b/htmlcov/status.json
@@ -0,0 +1 @@
+{"note":"This file is an internal implementation detail to speed up HTML report generation. Its format can change at any time. You might be looking for the JSON report: https://coverage.rtfd.io/cmd.html#cmd-json","format":5,"version":"7.8.2","globals":"06fbd4730370e0840a9d3c86ead59982","files":{"z_145eef247bfb46b6___init___py":{"hash":"e6baa73cda2916dad605215f937a92e1","index":{"url":"z_145eef247bfb46b6___init___py.html","file":"src\\__init__.py","description":"","nums":{"precision":0,"n_files":1,"n_statements":0,"n_excluded":0,"n_missing":0,"n_branches":0,"n_partial_branches":0,"n_missing_branches":0}}},"z_145eef247bfb46b6_masks_py":{"hash":"b53a5ecdc81c643b241601ed13f5bf9a","index":{"url":"z_145eef247bfb46b6_masks_py.html","file":"src\\masks.py","description":"","nums":{"precision":0,"n_files":1,"n_statements":11,"n_excluded":0,"n_missing":0,"n_branches":0,"n_partial_branches":0,"n_missing_branches":0}}},"z_145eef247bfb46b6_processing_py":{"hash":"c1135b969c8fe382fbe8854465b30356","index":{"url":"z_145eef247bfb46b6_processing_py.html","file":"src\\processing.py","description":"","nums":{"precision":0,"n_files":1,"n_statements":6,"n_excluded":0,"n_missing":1,"n_branches":0,"n_partial_branches":0,"n_missing_branches":0}}},"z_145eef247bfb46b6_widget_py":{"hash":"fdff31560d35275081e8e56f5d3578b1","index":{"url":"z_145eef247bfb46b6_widget_py.html","file":"src\\widget.py","description":"","nums":{"precision":0,"n_files":1,"n_statements":24,"n_excluded":0,"n_missing":0,"n_branches":0,"n_partial_branches":0,"n_missing_branches":0}}}}}
\ No newline at end of file
diff --git a/htmlcov/style_cb_718ce007.css b/htmlcov/style_cb_718ce007.css
new file mode 100644
index 0000000..3cdaf05
--- /dev/null
+++ b/htmlcov/style_cb_718ce007.css
@@ -0,0 +1,337 @@
+@charset "UTF-8";
+/* Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 */
+/* For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt */
+/* Don't edit this .css file. Edit the .scss file instead! */
+html, body, h1, h2, h3, p, table, td, th { margin: 0; padding: 0; border: 0; font-weight: inherit; font-style: inherit; font-size: 100%; font-family: inherit; vertical-align: baseline; }
+
+body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; font-size: 1em; background: #fff; color: #000; }
+
+@media (prefers-color-scheme: dark) { body { background: #1e1e1e; } }
+
+@media (prefers-color-scheme: dark) { body { color: #eee; } }
+
+html > body { font-size: 16px; }
+
+a:active, a:focus { outline: 2px dashed #007acc; }
+
+p { font-size: .875em; line-height: 1.4em; }
+
+table { border-collapse: collapse; }
+
+td { vertical-align: top; }
+
+table tr.hidden { display: none !important; }
+
+p#no_rows { display: none; font-size: 1.15em; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; }
+
+a.nav { text-decoration: none; color: inherit; }
+
+a.nav:hover { text-decoration: underline; color: inherit; }
+
+.hidden { display: none; }
+
+header { background: #f8f8f8; width: 100%; z-index: 2; border-bottom: 1px solid #ccc; }
+
+@media (prefers-color-scheme: dark) { header { background: black; } }
+
+@media (prefers-color-scheme: dark) { header { border-color: #333; } }
+
+header .content { padding: 1rem 3.5rem; }
+
+header h2 { margin-top: .5em; font-size: 1em; }
+
+header h2 a.button { font-family: inherit; font-size: inherit; border: 1px solid; border-radius: .2em; background: #eee; color: inherit; text-decoration: none; padding: .1em .5em; margin: 1px calc(.1em + 1px); cursor: pointer; border-color: #ccc; }
+
+@media (prefers-color-scheme: dark) { header h2 a.button { background: #333; } }
+
+@media (prefers-color-scheme: dark) { header h2 a.button { border-color: #444; } }
+
+header h2 a.button.current { border: 2px solid; background: #fff; border-color: #999; cursor: default; }
+
+@media (prefers-color-scheme: dark) { header h2 a.button.current { background: #1e1e1e; } }
+
+@media (prefers-color-scheme: dark) { header h2 a.button.current { border-color: #777; } }
+
+header p.text { margin: .5em 0 -.5em; color: #666; font-style: italic; }
+
+@media (prefers-color-scheme: dark) { header p.text { color: #aaa; } }
+
+header.sticky { position: fixed; left: 0; right: 0; height: 2.5em; }
+
+header.sticky .text { display: none; }
+
+header.sticky h1, header.sticky h2 { font-size: 1em; margin-top: 0; display: inline-block; }
+
+header.sticky .content { padding: 0.5rem 3.5rem; }
+
+header.sticky .content p { font-size: 1em; }
+
+header.sticky ~ #source { padding-top: 6.5em; }
+
+main { position: relative; z-index: 1; }
+
+footer { margin: 1rem 3.5rem; }
+
+footer .content { padding: 0; color: #666; font-style: italic; }
+
+@media (prefers-color-scheme: dark) { footer .content { color: #aaa; } }
+
+#index { margin: 1rem 0 0 3.5rem; }
+
+h1 { font-size: 1.25em; display: inline-block; }
+
+#filter_container { float: right; margin: 0 2em 0 0; line-height: 1.66em; }
+
+#filter_container #filter { width: 10em; padding: 0.2em 0.5em; border: 2px solid #ccc; background: #fff; color: #000; }
+
+@media (prefers-color-scheme: dark) { #filter_container #filter { border-color: #444; } }
+
+@media (prefers-color-scheme: dark) { #filter_container #filter { background: #1e1e1e; } }
+
+@media (prefers-color-scheme: dark) { #filter_container #filter { color: #eee; } }
+
+#filter_container #filter:focus { border-color: #007acc; }
+
+#filter_container :disabled ~ label { color: #ccc; }
+
+@media (prefers-color-scheme: dark) { #filter_container :disabled ~ label { color: #444; } }
+
+#filter_container label { font-size: .875em; color: #666; }
+
+@media (prefers-color-scheme: dark) { #filter_container label { color: #aaa; } }
+
+header button { font-family: inherit; font-size: inherit; border: 1px solid; border-radius: .2em; background: #eee; color: inherit; text-decoration: none; padding: .1em .5em; margin: 1px calc(.1em + 1px); cursor: pointer; border-color: #ccc; }
+
+@media (prefers-color-scheme: dark) { header button { background: #333; } }
+
+@media (prefers-color-scheme: dark) { header button { border-color: #444; } }
+
+header button:active, header button:focus { outline: 2px dashed #007acc; }
+
+header button.run { background: #eeffee; }
+
+@media (prefers-color-scheme: dark) { header button.run { background: #373d29; } }
+
+header button.run.show_run { background: #dfd; border: 2px solid #00dd00; margin: 0 .1em; }
+
+@media (prefers-color-scheme: dark) { header button.run.show_run { background: #373d29; } }
+
+header button.mis { background: #ffeeee; }
+
+@media (prefers-color-scheme: dark) { header button.mis { background: #4b1818; } }
+
+header button.mis.show_mis { background: #fdd; border: 2px solid #ff0000; margin: 0 .1em; }
+
+@media (prefers-color-scheme: dark) { header button.mis.show_mis { background: #4b1818; } }
+
+header button.exc { background: #f7f7f7; }
+
+@media (prefers-color-scheme: dark) { header button.exc { background: #333; } }
+
+header button.exc.show_exc { background: #eee; border: 2px solid #808080; margin: 0 .1em; }
+
+@media (prefers-color-scheme: dark) { header button.exc.show_exc { background: #333; } }
+
+header button.par { background: #ffffd5; }
+
+@media (prefers-color-scheme: dark) { header button.par { background: #650; } }
+
+header button.par.show_par { background: #ffa; border: 2px solid #bbbb00; margin: 0 .1em; }
+
+@media (prefers-color-scheme: dark) { header button.par.show_par { background: #650; } }
+
+#help_panel, #source p .annotate.long { display: none; position: absolute; z-index: 999; background: #ffffcc; border: 1px solid #888; border-radius: .2em; color: #333; padding: .25em .5em; }
+
+#source p .annotate.long { white-space: normal; float: right; top: 1.75em; right: 1em; height: auto; }
+
+#help_panel_wrapper { float: right; position: relative; }
+
+#keyboard_icon { margin: 5px; }
+
+#help_panel_state { display: none; }
+
+#help_panel { top: 25px; right: 0; padding: .75em; border: 1px solid #883; color: #333; }
+
+#help_panel .keyhelp p { margin-top: .75em; }
+
+#help_panel .legend { font-style: italic; margin-bottom: 1em; }
+
+.indexfile #help_panel { width: 25em; }
+
+.pyfile #help_panel { width: 18em; }
+
+#help_panel_state:checked ~ #help_panel { display: block; }
+
+kbd { border: 1px solid black; border-color: #888 #333 #333 #888; padding: .1em .35em; font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-weight: bold; background: #eee; border-radius: 3px; }
+
+#source { padding: 1em 0 1em 3.5rem; font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
+
+#source p { position: relative; white-space: pre; }
+
+#source p * { box-sizing: border-box; }
+
+#source p .n { float: left; text-align: right; width: 3.5rem; box-sizing: border-box; margin-left: -3.5rem; padding-right: 1em; color: #999; user-select: none; }
+
+@media (prefers-color-scheme: dark) { #source p .n { color: #777; } }
+
+#source p .n.highlight { background: #ffdd00; }
+
+#source p .n a { scroll-margin-top: 6em; text-decoration: none; color: #999; }
+
+@media (prefers-color-scheme: dark) { #source p .n a { color: #777; } }
+
+#source p .n a:hover { text-decoration: underline; color: #999; }
+
+@media (prefers-color-scheme: dark) { #source p .n a:hover { color: #777; } }
+
+#source p .t { display: inline-block; width: 100%; box-sizing: border-box; margin-left: -.5em; padding-left: 0.3em; border-left: 0.2em solid #fff; }
+
+@media (prefers-color-scheme: dark) { #source p .t { border-color: #1e1e1e; } }
+
+#source p .t:hover { background: #f2f2f2; }
+
+@media (prefers-color-scheme: dark) { #source p .t:hover { background: #282828; } }
+
+#source p .t:hover ~ .r .annotate.long { display: block; }
+
+#source p .t .com { color: #008000; font-style: italic; line-height: 1px; }
+
+@media (prefers-color-scheme: dark) { #source p .t .com { color: #6a9955; } }
+
+#source p .t .key { font-weight: bold; line-height: 1px; }
+
+#source p .t .str { color: #0451a5; }
+
+@media (prefers-color-scheme: dark) { #source p .t .str { color: #9cdcfe; } }
+
+#source p.mis .t { border-left: 0.2em solid #ff0000; }
+
+#source p.mis.show_mis .t { background: #fdd; }
+
+@media (prefers-color-scheme: dark) { #source p.mis.show_mis .t { background: #4b1818; } }
+
+#source p.mis.show_mis .t:hover { background: #f2d2d2; }
+
+@media (prefers-color-scheme: dark) { #source p.mis.show_mis .t:hover { background: #532323; } }
+
+#source p.run .t { border-left: 0.2em solid #00dd00; }
+
+#source p.run.show_run .t { background: #dfd; }
+
+@media (prefers-color-scheme: dark) { #source p.run.show_run .t { background: #373d29; } }
+
+#source p.run.show_run .t:hover { background: #d2f2d2; }
+
+@media (prefers-color-scheme: dark) { #source p.run.show_run .t:hover { background: #404633; } }
+
+#source p.exc .t { border-left: 0.2em solid #808080; }
+
+#source p.exc.show_exc .t { background: #eee; }
+
+@media (prefers-color-scheme: dark) { #source p.exc.show_exc .t { background: #333; } }
+
+#source p.exc.show_exc .t:hover { background: #e2e2e2; }
+
+@media (prefers-color-scheme: dark) { #source p.exc.show_exc .t:hover { background: #3c3c3c; } }
+
+#source p.par .t { border-left: 0.2em solid #bbbb00; }
+
+#source p.par.show_par .t { background: #ffa; }
+
+@media (prefers-color-scheme: dark) { #source p.par.show_par .t { background: #650; } }
+
+#source p.par.show_par .t:hover { background: #f2f2a2; }
+
+@media (prefers-color-scheme: dark) { #source p.par.show_par .t:hover { background: #6d5d0c; } }
+
+#source p .r { position: absolute; top: 0; right: 2.5em; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; }
+
+#source p .annotate { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; color: #666; padding-right: .5em; }
+
+@media (prefers-color-scheme: dark) { #source p .annotate { color: #ddd; } }
+
+#source p .annotate.short:hover ~ .long { display: block; }
+
+#source p .annotate.long { width: 30em; right: 2.5em; }
+
+#source p input { display: none; }
+
+#source p input ~ .r label.ctx { cursor: pointer; border-radius: .25em; }
+
+#source p input ~ .r label.ctx::before { content: "▶ "; }
+
+#source p input ~ .r label.ctx:hover { background: #e8f4ff; color: #666; }
+
+@media (prefers-color-scheme: dark) { #source p input ~ .r label.ctx:hover { background: #0f3a42; } }
+
+@media (prefers-color-scheme: dark) { #source p input ~ .r label.ctx:hover { color: #aaa; } }
+
+#source p input:checked ~ .r label.ctx { background: #d0e8ff; color: #666; border-radius: .75em .75em 0 0; padding: 0 .5em; margin: -.25em 0; }
+
+@media (prefers-color-scheme: dark) { #source p input:checked ~ .r label.ctx { background: #056; } }
+
+@media (prefers-color-scheme: dark) { #source p input:checked ~ .r label.ctx { color: #aaa; } }
+
+#source p input:checked ~ .r label.ctx::before { content: "▼ "; }
+
+#source p input:checked ~ .ctxs { padding: .25em .5em; overflow-y: scroll; max-height: 10.5em; }
+
+#source p label.ctx { color: #999; display: inline-block; padding: 0 .5em; font-size: .8333em; }
+
+@media (prefers-color-scheme: dark) { #source p label.ctx { color: #777; } }
+
+#source p .ctxs { display: block; max-height: 0; overflow-y: hidden; transition: all .2s; padding: 0 .5em; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; white-space: nowrap; background: #d0e8ff; border-radius: .25em; margin-right: 1.75em; text-align: right; }
+
+@media (prefers-color-scheme: dark) { #source p .ctxs { background: #056; } }
+
+#index { font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 0.875em; }
+
+#index table.index { margin-left: -.5em; }
+
+#index td, #index th { text-align: right; padding: .25em .5em; border-bottom: 1px solid #eee; }
+
+@media (prefers-color-scheme: dark) { #index td, #index th { border-color: #333; } }
+
+#index td.name, #index th.name { text-align: left; width: auto; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; min-width: 15em; }
+
+#index th { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; font-style: italic; color: #333; cursor: pointer; }
+
+@media (prefers-color-scheme: dark) { #index th { color: #ddd; } }
+
+#index th:hover { background: #eee; }
+
+@media (prefers-color-scheme: dark) { #index th:hover { background: #333; } }
+
+#index th .arrows { color: #666; font-size: 85%; font-family: sans-serif; font-style: normal; pointer-events: none; }
+
+#index th[aria-sort="ascending"], #index th[aria-sort="descending"] { white-space: nowrap; background: #eee; padding-left: .5em; }
+
+@media (prefers-color-scheme: dark) { #index th[aria-sort="ascending"], #index th[aria-sort="descending"] { background: #333; } }
+
+#index th[aria-sort="ascending"] .arrows::after { content: " ▲"; }
+
+#index th[aria-sort="descending"] .arrows::after { content: " ▼"; }
+
+#index td.name { font-size: 1.15em; }
+
+#index td.name a { text-decoration: none; color: inherit; }
+
+#index td.name .no-noun { font-style: italic; }
+
+#index tr.total td, #index tr.total_dynamic td { font-weight: bold; border-top: 1px solid #ccc; border-bottom: none; }
+
+#index tr.region:hover { background: #eee; }
+
+@media (prefers-color-scheme: dark) { #index tr.region:hover { background: #333; } }
+
+#index tr.region:hover td.name { text-decoration: underline; color: inherit; }
+
+#scroll_marker { position: fixed; z-index: 3; right: 0; top: 0; width: 16px; height: 100%; background: #fff; border-left: 1px solid #eee; will-change: transform; }
+
+@media (prefers-color-scheme: dark) { #scroll_marker { background: #1e1e1e; } }
+
+@media (prefers-color-scheme: dark) { #scroll_marker { border-color: #333; } }
+
+#scroll_marker .marker { background: #ccc; position: absolute; min-height: 3px; width: 100%; }
+
+@media (prefers-color-scheme: dark) { #scroll_marker .marker { background: #444; } }
diff --git a/htmlcov/z_145eef247bfb46b6___init___py.html b/htmlcov/z_145eef247bfb46b6___init___py.html
new file mode 100644
index 0000000..aee4e4e
--- /dev/null
+++ b/htmlcov/z_145eef247bfb46b6___init___py.html
@@ -0,0 +1,97 @@
+
+
+
+
+ Coverage for src\__init__.py: 100%
+
+
+
+
+
+
+
+
+
+
+
diff --git a/htmlcov/z_145eef247bfb46b6_masks_py.html b/htmlcov/z_145eef247bfb46b6_masks_py.html
new file mode 100644
index 0000000..f778d07
--- /dev/null
+++ b/htmlcov/z_145eef247bfb46b6_masks_py.html
@@ -0,0 +1,135 @@
+
+
+
+
+ Coverage for src\masks.py: 100%
+
+
+
+
+
+
+
+ 1INVALID_CARD_NUMBER = "Неверный номер карты!"
+ 2
+ 3
+ 4def get_mask_card_number(number_card: str) -> str:
+ 5 """
+ 6 Данная функция маскирует номер банковской карты.
+ 7
+ 8 На вход принимается строка.
+ 9
+ 10 На выходе форматированная строка.
+ 11
+ 12 :param number_card:
+ 13 :return:
+ 14 """
+ 15
+ 16 digits = "".join(char for char in number_card if char.isdigit())
+ 17
+ 18 if len(digits) != 16:
+ 19 raise ValueError(INVALID_CARD_NUMBER)
+ 20
+ 21 return f"{digits[0:4]} {digits[4:6]}** **** {digits[-4:]}"
+ 22
+ 23
+ 24def get_mask_account(account_number: str) -> str:
+ 25 """
+ 26 Данная функция маскирует номер счёта.
+ 27
+ 28 На вход принимается строка.
+ 29
+ 30 На выходе строка.
+ 31
+ 32 :param account_number:
+ 33 :return:
+ 34 """
+ 35 digits = "".join(char for char in account_number if char.isdigit())
+ 36 if len(digits) != 20:
+ 37 raise ValueError(INVALID_CARD_NUMBER)
+ 38 return f"**{digits[-4:]}"
+
+
+
+
diff --git a/htmlcov/z_145eef247bfb46b6_processing_py.html b/htmlcov/z_145eef247bfb46b6_processing_py.html
new file mode 100644
index 0000000..8a36e4b
--- /dev/null
+++ b/htmlcov/z_145eef247bfb46b6_processing_py.html
@@ -0,0 +1,122 @@
+
+
+
+
+ Coverage for src\processing.py: 83%
+
+
+
+
+
+
+
+ 1def filter_by_state(data_list: list, state: str = "EXECUTED") -> list:
+ 2 """
+ 3 Функция возвращает новый список словарей, содержащий только те словари, у которых
+ 4 ключ state соответствует указанному значению.
+ 5
+ 6 :param data_list:
+ 7 :param state:
+ 8 :return:
+ 9 """
+ 10
+ 11 return [item for item in data_list if item.get("state") == state]
+ 12
+ 13
+ 14def sort_by_date(date_list: list, ascending: bool = True) -> list:
+ 15 """
+ 16 Функция возвращает новый список, отсортированный по дате (date)
+ 17
+ 18 :param date_list:
+ 19 :param ascending:
+ 20 :return:
+ 21 """
+ 22 if not date_list:
+ 23 return []
+ 24
+ 25 return sorted(date_list, key=lambda x: x.get("date", 0), reverse=ascending)
+
+
+
+
diff --git a/htmlcov/z_145eef247bfb46b6_widget_py.html b/htmlcov/z_145eef247bfb46b6_widget_py.html
new file mode 100644
index 0000000..820508c
--- /dev/null
+++ b/htmlcov/z_145eef247bfb46b6_widget_py.html
@@ -0,0 +1,164 @@
+
+
+
+
+ Coverage for src\widget.py: 100%
+
+
+
+
+
+
+
+ 1from datetime import datetime
+ 2
+ 3from src.masks import get_mask_account, get_mask_card_number
+ 4
+ 5
+ 6def mask_account_card(card_info_sting: str = "") -> str:
+ 7 """
+ 8 Принимает на вход строку с наименованием карты и её номером
+ 9
+ 10 После чего номер маскирует
+ 11
+ 12 На выходе получаем наименование карты и маскированный номер
+ 13
+ 14 :param card_info_sting:
+ 15 :return:
+ 16
+ 17 """
+ 18 card_error_message: str = "Неверный номер карты!"
+ 19 if not card_info_sting.strip():
+ 20 return card_error_message
+ 21
+ 22 # приводим строку к требуемому виду
+ 23 normalized_card_sting: str = card_info_sting.lower().strip()
+ 24 # Извлечение цифр из строки
+ 25 all_digits: str = "".join(char for char in normalized_card_sting if char.isdigit())
+ 26 # Извлекаю имя карты
+ 27 card_name: str = "".join(char for char in card_info_sting if not char.isdigit() and char not in ("-", "/")).strip()
+ 28
+ 29 # На всякий случай в переменной сообщение об ошибке.
+ 30 # Если маскировка карты пройдёт успешно, то в этой переменной будет результат
+ 31 mask_card_info: str = card_error_message
+ 32
+ 33 # Проверяю счёт унас на входе или иная невидаль
+ 34 if ("счет " in normalized_card_sting) or ("счёт " in normalized_card_sting):
+ 35 # если счёт, то смотрим, 20ть ли цифирь, если да, то маскируем
+ 36 if len(all_digits) == 20:
+ 37 mask_card_info = card_name + " " + get_mask_account(all_digits)
+ 38 else:
+ 39 # если не счёт, то возможно карта, тогда смотрим 16ть ли цифирь
+ 40 # и если 16ть, маскируем, если нет, то просто выходим
+ 41 if len(all_digits) == 16:
+ 42 mask_card_info = card_name + " " + get_mask_card_number(all_digits)
+ 43
+ 44 # если хотя бы одна функция в условии выше отработала, тогда возвращаем результат
+ 45 # если же нет, то записанное ранее сообщение об ошибке
+ 46 return mask_card_info
+ 47
+ 48
+ 49def get_date(iso_date: str) -> str:
+ 50 """
+ 51 принимает на вход строку с датой в ISO 8601 формате
+ 52
+ 53 "2024-03-11T02:26:18.671407"
+ 54
+ 55 и возвращает строку с датой в формате
+ 56
+ 57 "ДД.ММ.ГГГГ" ("11.03.2024")
+ 58 :param iso_date:
+ 59 :return:
+ 60 """
+ 61 error_message: str = "Неверный формат даты!"
+ 62 if not iso_date:
+ 63 return error_message
+ 64 try:
+ 65 return datetime.fromisoformat(iso_date).strftime("%d.%m.%Y")
+ 66 except (ValueError, TypeError):
+ 67 return error_message
+
+
+
+
diff --git a/poetry.lock b/poetry.lock
index 721fa1b..736686a 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -180,12 +180,92 @@ version = "0.4.6"
description = "Cross-platform colored terminal text."
optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"
-groups = ["lint"]
-markers = "platform_system == \"Windows\""
+groups = ["dev", "lint"]
files = [
{file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"},
{file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"},
]
+markers = {dev = "sys_platform == \"win32\"", lint = "platform_system == \"Windows\""}
+
+[[package]]
+name = "coverage"
+version = "7.8.2"
+description = "Code coverage measurement for Python"
+optional = false
+python-versions = ">=3.9"
+groups = ["dev"]
+files = [
+ {file = "coverage-7.8.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:bd8ec21e1443fd7a447881332f7ce9d35b8fbd2849e761bb290b584535636b0a"},
+ {file = "coverage-7.8.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:4c26c2396674816deaeae7ded0e2b42c26537280f8fe313335858ffff35019be"},
+ {file = "coverage-7.8.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1aec326ed237e5880bfe69ad41616d333712c7937bcefc1343145e972938f9b3"},
+ {file = "coverage-7.8.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5e818796f71702d7a13e50c70de2a1924f729228580bcba1607cccf32eea46e6"},
+ {file = "coverage-7.8.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:546e537d9e24efc765c9c891328f30f826e3e4808e31f5d0f87c4ba12bbd1622"},
+ {file = "coverage-7.8.2-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:ab9b09a2349f58e73f8ebc06fac546dd623e23b063e5398343c5270072e3201c"},
+ {file = "coverage-7.8.2-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:fd51355ab8a372d89fb0e6a31719e825cf8df8b6724bee942fb5b92c3f016ba3"},
+ {file = "coverage-7.8.2-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:0774df1e093acb6c9e4d58bce7f86656aeed6c132a16e2337692c12786b32404"},
+ {file = "coverage-7.8.2-cp310-cp310-win32.whl", hash = "sha256:00f2e2f2e37f47e5f54423aeefd6c32a7dbcedc033fcd3928a4f4948e8b96af7"},
+ {file = "coverage-7.8.2-cp310-cp310-win_amd64.whl", hash = "sha256:145b07bea229821d51811bf15eeab346c236d523838eda395ea969d120d13347"},
+ {file = "coverage-7.8.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b99058eef42e6a8dcd135afb068b3d53aff3921ce699e127602efff9956457a9"},
+ {file = "coverage-7.8.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5feb7f2c3e6ea94d3b877def0270dff0947b8d8c04cfa34a17be0a4dc1836879"},
+ {file = "coverage-7.8.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:670a13249b957bb9050fab12d86acef7bf8f6a879b9d1a883799276e0d4c674a"},
+ {file = "coverage-7.8.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0bdc8bf760459a4a4187b452213e04d039990211f98644c7292adf1e471162b5"},
+ {file = "coverage-7.8.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:07a989c867986c2a75f158f03fdb413128aad29aca9d4dbce5fc755672d96f11"},
+ {file = "coverage-7.8.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:2db10dedeb619a771ef0e2949ccba7b75e33905de959c2643a4607bef2f3fb3a"},
+ {file = "coverage-7.8.2-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:e6ea7dba4e92926b7b5f0990634b78ea02f208d04af520c73a7c876d5a8d36cb"},
+ {file = "coverage-7.8.2-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:ef2f22795a7aca99fc3c84393a55a53dd18ab8c93fb431004e4d8f0774150f54"},
+ {file = "coverage-7.8.2-cp311-cp311-win32.whl", hash = "sha256:641988828bc18a6368fe72355df5f1703e44411adbe49bba5644b941ce6f2e3a"},
+ {file = "coverage-7.8.2-cp311-cp311-win_amd64.whl", hash = "sha256:8ab4a51cb39dc1933ba627e0875046d150e88478dbe22ce145a68393e9652975"},
+ {file = "coverage-7.8.2-cp311-cp311-win_arm64.whl", hash = "sha256:8966a821e2083c74d88cca5b7dcccc0a3a888a596a04c0b9668a891de3a0cc53"},
+ {file = "coverage-7.8.2-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:e2f6fe3654468d061942591aef56686131335b7a8325684eda85dacdf311356c"},
+ {file = "coverage-7.8.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:76090fab50610798cc05241bf83b603477c40ee87acd358b66196ab0ca44ffa1"},
+ {file = "coverage-7.8.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2bd0a0a5054be160777a7920b731a0570284db5142abaaf81bcbb282b8d99279"},
+ {file = "coverage-7.8.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:da23ce9a3d356d0affe9c7036030b5c8f14556bd970c9b224f9c8205505e3b99"},
+ {file = "coverage-7.8.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c9392773cffeb8d7e042a7b15b82a414011e9d2b5fdbbd3f7e6a6b17d5e21b20"},
+ {file = "coverage-7.8.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:876cbfd0b09ce09d81585d266c07a32657beb3eaec896f39484b631555be0fe2"},
+ {file = "coverage-7.8.2-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:3da9b771c98977a13fbc3830f6caa85cae6c9c83911d24cb2d218e9394259c57"},
+ {file = "coverage-7.8.2-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:9a990f6510b3292686713bfef26d0049cd63b9c7bb17e0864f133cbfd2e6167f"},
+ {file = "coverage-7.8.2-cp312-cp312-win32.whl", hash = "sha256:bf8111cddd0f2b54d34e96613e7fbdd59a673f0cf5574b61134ae75b6f5a33b8"},
+ {file = "coverage-7.8.2-cp312-cp312-win_amd64.whl", hash = "sha256:86a323a275e9e44cdf228af9b71c5030861d4d2610886ab920d9945672a81223"},
+ {file = "coverage-7.8.2-cp312-cp312-win_arm64.whl", hash = "sha256:820157de3a589e992689ffcda8639fbabb313b323d26388d02e154164c57b07f"},
+ {file = "coverage-7.8.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:ea561010914ec1c26ab4188aef8b1567272ef6de096312716f90e5baa79ef8ca"},
+ {file = "coverage-7.8.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:cb86337a4fcdd0e598ff2caeb513ac604d2f3da6d53df2c8e368e07ee38e277d"},
+ {file = "coverage-7.8.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:26a4636ddb666971345541b59899e969f3b301143dd86b0ddbb570bd591f1e85"},
+ {file = "coverage-7.8.2-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5040536cf9b13fb033f76bcb5e1e5cb3b57c4807fef37db9e0ed129c6a094257"},
+ {file = "coverage-7.8.2-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dc67994df9bcd7e0150a47ef41278b9e0a0ea187caba72414b71dc590b99a108"},
+ {file = "coverage-7.8.2-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:6e6c86888fd076d9e0fe848af0a2142bf606044dc5ceee0aa9eddb56e26895a0"},
+ {file = "coverage-7.8.2-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:684ca9f58119b8e26bef860db33524ae0365601492e86ba0b71d513f525e7050"},
+ {file = "coverage-7.8.2-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:8165584ddedb49204c4e18da083913bdf6a982bfb558632a79bdaadcdafd0d48"},
+ {file = "coverage-7.8.2-cp313-cp313-win32.whl", hash = "sha256:34759ee2c65362163699cc917bdb2a54114dd06d19bab860725f94ef45a3d9b7"},
+ {file = "coverage-7.8.2-cp313-cp313-win_amd64.whl", hash = "sha256:2f9bc608fbafaee40eb60a9a53dbfb90f53cc66d3d32c2849dc27cf5638a21e3"},
+ {file = "coverage-7.8.2-cp313-cp313-win_arm64.whl", hash = "sha256:9fe449ee461a3b0c7105690419d0b0aba1232f4ff6d120a9e241e58a556733f7"},
+ {file = "coverage-7.8.2-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:8369a7c8ef66bded2b6484053749ff220dbf83cba84f3398c84c51a6f748a008"},
+ {file = "coverage-7.8.2-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:159b81df53a5fcbc7d45dae3adad554fdbde9829a994e15227b3f9d816d00b36"},
+ {file = "coverage-7.8.2-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e6fcbbd35a96192d042c691c9e0c49ef54bd7ed865846a3c9d624c30bb67ce46"},
+ {file = "coverage-7.8.2-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:05364b9cc82f138cc86128dc4e2e1251c2981a2218bfcd556fe6b0fbaa3501be"},
+ {file = "coverage-7.8.2-cp313-cp313t-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:46d532db4e5ff3979ce47d18e2fe8ecad283eeb7367726da0e5ef88e4fe64740"},
+ {file = "coverage-7.8.2-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:4000a31c34932e7e4fa0381a3d6deb43dc0c8f458e3e7ea6502e6238e10be625"},
+ {file = "coverage-7.8.2-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:43ff5033d657cd51f83015c3b7a443287250dc14e69910577c3e03bd2e06f27b"},
+ {file = "coverage-7.8.2-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:94316e13f0981cbbba132c1f9f365cac1d26716aaac130866ca812006f662199"},
+ {file = "coverage-7.8.2-cp313-cp313t-win32.whl", hash = "sha256:3f5673888d3676d0a745c3d0e16da338c5eea300cb1f4ada9c872981265e76d8"},
+ {file = "coverage-7.8.2-cp313-cp313t-win_amd64.whl", hash = "sha256:2c08b05ee8d7861e45dc5a2cc4195c8c66dca5ac613144eb6ebeaff2d502e73d"},
+ {file = "coverage-7.8.2-cp313-cp313t-win_arm64.whl", hash = "sha256:1e1448bb72b387755e1ff3ef1268a06617afd94188164960dba8d0245a46004b"},
+ {file = "coverage-7.8.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:496948261eaac5ac9cf43f5d0a9f6eb7a6d4cb3bedb2c5d294138142f5c18f2a"},
+ {file = "coverage-7.8.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:eacd2de0d30871eff893bab0b67840a96445edcb3c8fd915e6b11ac4b2f3fa6d"},
+ {file = "coverage-7.8.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b039ffddc99ad65d5078ef300e0c7eed08c270dc26570440e3ef18beb816c1ca"},
+ {file = "coverage-7.8.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0e49824808d4375ede9dd84e9961a59c47f9113039f1a525e6be170aa4f5c34d"},
+ {file = "coverage-7.8.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b069938961dfad881dc2f8d02b47645cd2f455d3809ba92a8a687bf513839787"},
+ {file = "coverage-7.8.2-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:de77c3ba8bb686d1c411e78ee1b97e6e0b963fb98b1637658dd9ad2c875cf9d7"},
+ {file = "coverage-7.8.2-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:1676628065a498943bd3f64f099bb573e08cf1bc6088bbe33cf4424e0876f4b3"},
+ {file = "coverage-7.8.2-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:8e1a26e7e50076e35f7afafde570ca2b4d7900a491174ca357d29dece5aacee7"},
+ {file = "coverage-7.8.2-cp39-cp39-win32.whl", hash = "sha256:6782a12bf76fa61ad9350d5a6ef5f3f020b57f5e6305cbc663803f2ebd0f270a"},
+ {file = "coverage-7.8.2-cp39-cp39-win_amd64.whl", hash = "sha256:1efa4166ba75ccefd647f2d78b64f53f14fb82622bc94c5a5cb0a622f50f1c9e"},
+ {file = "coverage-7.8.2-pp39.pp310.pp311-none-any.whl", hash = "sha256:ec455eedf3ba0bbdf8f5a570012617eb305c63cb9f03428d39bf544cb2b94837"},
+ {file = "coverage-7.8.2-py3-none-any.whl", hash = "sha256:726f32ee3713f7359696331a18daf0c3b3a70bb0ae71141b9d3c52be7c595e32"},
+ {file = "coverage-7.8.2.tar.gz", hash = "sha256:a886d531373a1f6ff9fad2a2ba4a045b68467b779ae729ee0b3b10ac20033b27"},
+]
+
+[package.extras]
+toml = ["tomli ; python_full_version <= \"3.11.0a6\""]
[[package]]
name = "flake8"
@@ -219,6 +299,18 @@ files = [
[package.extras]
all = ["flake8 (>=7.1.1)", "mypy (>=1.11.2)", "pytest (>=8.3.2)", "ruff (>=0.6.2)"]
+[[package]]
+name = "iniconfig"
+version = "2.1.0"
+description = "brain-dead simple config-ini parsing"
+optional = false
+python-versions = ">=3.8"
+groups = ["dev"]
+files = [
+ {file = "iniconfig-2.1.0-py3-none-any.whl", hash = "sha256:9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760"},
+ {file = "iniconfig-2.1.0.tar.gz", hash = "sha256:3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7"},
+]
+
[[package]]
name = "isort"
version = "6.0.1"
@@ -318,7 +410,7 @@ version = "25.0"
description = "Core utilities for Python packages"
optional = false
python-versions = ">=3.8"
-groups = ["lint"]
+groups = ["dev", "lint"]
files = [
{file = "packaging-25.0-py3-none-any.whl", hash = "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484"},
{file = "packaging-25.0.tar.gz", hash = "sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f"},
@@ -353,6 +445,22 @@ docs = ["furo (>=2024.8.6)", "proselint (>=0.14)", "sphinx (>=8.1.3)", "sphinx-a
test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=8.3.4)", "pytest-cov (>=6)", "pytest-mock (>=3.14)"]
type = ["mypy (>=1.14.1)"]
+[[package]]
+name = "pluggy"
+version = "1.6.0"
+description = "plugin and hook calling mechanisms for python"
+optional = false
+python-versions = ">=3.9"
+groups = ["dev"]
+files = [
+ {file = "pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746"},
+ {file = "pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3"},
+]
+
+[package.extras]
+dev = ["pre-commit", "tox"]
+testing = ["coverage", "pytest", "pytest-benchmark"]
+
[[package]]
name = "poetry-core"
version = "2.1.3"
@@ -389,6 +497,46 @@ files = [
{file = "pyflakes-3.3.2.tar.gz", hash = "sha256:6dfd61d87b97fba5dcfaaf781171ac16be16453be6d816147989e7f6e6a9576b"},
]
+[[package]]
+name = "pytest"
+version = "8.3.5"
+description = "pytest: simple powerful testing with Python"
+optional = false
+python-versions = ">=3.8"
+groups = ["dev"]
+files = [
+ {file = "pytest-8.3.5-py3-none-any.whl", hash = "sha256:c69214aa47deac29fad6c2a4f590b9c4a9fdb16a403176fe154b79c0b4d4d820"},
+ {file = "pytest-8.3.5.tar.gz", hash = "sha256:f4efe70cc14e511565ac476b57c279e12a855b11f48f212af1080ef2263d3845"},
+]
+
+[package.dependencies]
+colorama = {version = "*", markers = "sys_platform == \"win32\""}
+iniconfig = "*"
+packaging = "*"
+pluggy = ">=1.5,<2"
+
+[package.extras]
+dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"]
+
+[[package]]
+name = "pytest-cov"
+version = "6.1.1"
+description = "Pytest plugin for measuring coverage."
+optional = false
+python-versions = ">=3.9"
+groups = ["dev"]
+files = [
+ {file = "pytest_cov-6.1.1-py3-none-any.whl", hash = "sha256:bddf29ed2d0ab6f4df17b4c55b0a657287db8684af9c42ea546b21b1041b3dde"},
+ {file = "pytest_cov-6.1.1.tar.gz", hash = "sha256:46935f7aaefba760e716c2ebfbe1c216240b9592966e7da99ea8292d4d3e2a0a"},
+]
+
+[package.dependencies]
+coverage = {version = ">=7.5", extras = ["toml"]}
+pytest = ">=4.6"
+
+[package.extras]
+testing = ["fields", "hunter", "process-tests", "pytest-xdist", "virtualenv"]
+
[[package]]
name = "requests"
version = "2.32.3"
@@ -456,4 +604,4 @@ zstd = ["zstandard (>=0.18.0)"]
[metadata]
lock-version = "2.1"
python-versions = "^3.13"
-content-hash = "590bbe3a739b0b5b00cca5b34e36c141a477aefbd2b405901829dda11775ba6a"
+content-hash = "8232cc0101fe3c9cfd88754fe7267b5aeab0a100201a6dd987165045c63332fb"
diff --git a/pyproject.toml b/pyproject.toml
index e8926f2..90b80dc 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -13,6 +13,8 @@ shell = "^1.0.1"
[tool.poetry.group.dev.dependencies]
requests = "^2.32.3"
+pytest = "^8.3.5"
+pytest-cov = "^6.1.1"
[tool.poetry.group.lint.dependencies]
diff --git a/src/__pycache__/__init__.cpython-313.pyc b/src/__pycache__/__init__.cpython-313.pyc
deleted file mode 100644
index 9e09270..0000000
Binary files a/src/__pycache__/__init__.cpython-313.pyc and /dev/null differ
diff --git a/src/__pycache__/masks.cpython-313.pyc b/src/__pycache__/masks.cpython-313.pyc
deleted file mode 100644
index 97ef03d..0000000
Binary files a/src/__pycache__/masks.cpython-313.pyc and /dev/null differ
diff --git a/src/masks.py b/src/masks.py
index 50cc2eb..9d4b186 100644
--- a/src/masks.py
+++ b/src/masks.py
@@ -1,3 +1,6 @@
+INVALID_CARD_NUMBER = "Неверный номер карты!"
+
+
def get_mask_card_number(number_card: str) -> str:
"""
Данная функция маскирует номер банковской карты.
@@ -9,13 +12,13 @@ def get_mask_card_number(number_card: str) -> str:
:param number_card:
:return:
"""
- number_card = number_card.strip()
- if len(number_card) == 16 and number_card.isdigit():
- hidden_card_number: str = f"{number_card[0:4]} {number_card[4:6]}** **** {number_card[-4:]}"
- return hidden_card_number
- else:
- return "Неверный номер карты!"
+ digits = "".join(char for char in number_card if char.isdigit())
+
+ if len(digits) != 16:
+ raise ValueError(INVALID_CARD_NUMBER)
+
+ return f"{digits[0:4]} {digits[4:6]}** **** {digits[-4:]}"
def get_mask_account(account_number: str) -> str:
@@ -29,8 +32,7 @@ def get_mask_account(account_number: str) -> str:
:param account_number:
:return:
"""
- if account_number.isdigit() and len(account_number) == 20:
- account_number = account_number.strip()
- return f"**{account_number[-4:]}"
- else:
- return "Неверный номер карты!"
+ digits = "".join(char for char in account_number if char.isdigit())
+ if len(digits) != 20:
+ raise ValueError(INVALID_CARD_NUMBER)
+ return f"**{digits[-4:]}"
diff --git a/src/processing.py b/src/processing.py
new file mode 100644
index 0000000..beaa4e4
--- /dev/null
+++ b/src/processing.py
@@ -0,0 +1,25 @@
+def filter_by_state(data_list: list, state: str = "EXECUTED") -> list:
+ """
+ Функция возвращает новый список словарей, содержащий только те словари, у которых
+ ключ state соответствует указанному значению.
+
+ :param data_list:
+ :param state:
+ :return:
+ """
+
+ return [item for item in data_list if item.get("state") == state]
+
+
+def sort_by_date(date_list: list, ascending: bool = True) -> list:
+ """
+ Функция возвращает новый список, отсортированный по дате (date)
+
+ :param date_list:
+ :param ascending:
+ :return:
+ """
+ if not date_list:
+ return []
+
+ return sorted(date_list, key=lambda x: x.get("date", 0), reverse=ascending)
diff --git a/src/widget.py b/src/widget.py
index 7be5b38..7da70a6 100644
--- a/src/widget.py
+++ b/src/widget.py
@@ -1,3 +1,5 @@
+from datetime import datetime
+
from src.masks import get_mask_account, get_mask_card_number
@@ -7,33 +9,46 @@ def mask_account_card(card_info_sting: str = "") -> str:
После чего номер маскирует
- На выходе получаем наименование карты и маскированый номер
+ На выходе получаем наименование карты и маскированный номер
:param card_info_sting:
:return:
"""
+ card_error_message: str = "Неверный номер карты!"
+ if not card_info_sting.strip():
+ return card_error_message
- temp_card_info_sting: str = card_info_sting.lower().strip()
+ # приводим строку к требуемому виду
+ normalized_card_sting: str = card_info_sting.lower().strip()
+ # Извлечение цифр из строки
+ all_digits: str = "".join(char for char in normalized_card_sting if char.isdigit())
+ # Извлекаю имя карты
+ card_name: str = "".join(char for char in card_info_sting if not char.isdigit() and char not in ("-", "/")).strip()
- card_error_message: str = "Неверный номер карты!"
+ # На всякий случай в переменной сообщение об ошибке.
+ # Если маскировка карты пройдёт успешно, то в этой переменной будет результат
mask_card_info: str = card_error_message
- if card_info_sting != "":
- if ("счет " in temp_card_info_sting) or ("счёт " in temp_card_info_sting):
- temp_result = get_mask_account(temp_card_info_sting[5:])
- mask_card_info = "Счет " + temp_result if temp_result != card_error_message else card_error_message
- else:
- temp_result = get_mask_card_number(temp_card_info_sting[-16:])
- mask_card_info = (
- card_info_sting[0:-16] + temp_result if temp_result != card_error_message else card_error_message
- )
+ # Проверяю счёт унас на входе или иная невидаль
+ if ("счет " in normalized_card_sting) or ("счёт " in normalized_card_sting):
+ # если счёт, то смотрим, 20ть ли цифирь, если да, то маскируем
+ if len(all_digits) == 20:
+ mask_card_info = card_name + " " + get_mask_account(all_digits)
+ else:
+ # если не счёт, то возможно карта, тогда смотрим 16ть ли цифирь
+ # и если 16ть, маскируем, если нет, то просто выходим
+ if len(all_digits) == 16:
+ mask_card_info = card_name + " " + get_mask_card_number(all_digits)
+
+ # если хотя бы одна функция в условии выше отработала, тогда возвращаем результат
+ # если же нет, то записанное ранее сообщение об ошибке
return mask_card_info
def get_date(iso_date: str) -> str:
"""
- принимает на вход строку с датой в формате
+ принимает на вход строку с датой в ISO 8601 формате
"2024-03-11T02:26:18.671407"
@@ -43,5 +58,10 @@ def get_date(iso_date: str) -> str:
:param iso_date:
:return:
"""
-
- return iso_date[8:8 + 2] + "." + iso_date[5:5 + 2] + "." + iso_date[:4]
+ error_message: str = "Неверный формат даты!"
+ if not iso_date:
+ return error_message
+ try:
+ return datetime.fromisoformat(iso_date).strftime("%d.%m.%Y")
+ except (ValueError, TypeError):
+ return error_message
diff --git a/test/main.py b/test/main.py
index f551ce8..b0e7323 100644
--- a/test/main.py
+++ b/test/main.py
@@ -1,7 +1,8 @@
+from src.processing import filter_by_state, sort_by_date
from src.widget import get_date, mask_account_card
if __name__ == "__main__":
- #Проверочные вызовы
+ # Проверочные вызовы
print(mask_account_card("Счет 73654108430535874307"))
print(mask_account_card("Visa Platinum 7000712289606361"))
print(mask_account_card("Maestro 7000792108106361"))
@@ -17,7 +18,63 @@
print()
- # Если строка будет в таком виде, как сказано в задании... "2024-03-11T02:26:18.671407"
- # тогда всё у нас будет хорошо
+ # Если строка будет в таком виде, как сказано в задании...
+ # Тогда всё у нас будет хорошо
# ну либо опять не понял задание
print(get_date("2024-03-11T02:26:18.671407"))
+
+ print()
+
+ print(
+ "state ",
+ filter_by_state(
+ [
+ {"id": 41428829, "state": "EXECUTED", "date": "2019-07-03T18:35:29.512364"},
+ {"id": 939719570, "state": "EXECUTED", "date": "2018-06-30T02:08:58.425572"},
+ {"id": 594226727, "state": "CANCELED", "date": "2018-09-12T21:27:25.241689"},
+ {"id": 615064591, "state": "CANCELED", "date": "2018-10-14T08:21:33.419441"},
+ ]
+ ),
+ )
+
+ print(
+ "state ",
+ filter_by_state(
+ [
+ {"id": 41428829, "state": "EXECUTED", "date": "2019-07-03T18:35:29.512364"},
+ {"id": 939719570, "state": "EXECUTED", "date": "2018-06-30T02:08:58.425572"},
+ {"id": 594226727, "state": "CANCELED", "date": "2018-09-12T21:27:25.241689"},
+ {"id": 615064591, "state": "CANCELED", "date": "2018-10-14T08:21:33.419441"},
+ ],
+ "CANCELED",
+ ),
+ )
+
+ print(
+ "sort ",
+ sort_by_date(
+ [
+ {"id": 41428829, "state": "EXECUTED", "date": "2019-07-03T18:35:29.512364"},
+ {"id": 939719570, "state": "EXECUTED", "date": "2018-06-30T02:08:58.425572"},
+ {"id": 939719572, "state": "EXECUTED", "date": "2018-06-30T02:08:58.425572"},
+ {"id": 594226727, "state": "CANCELED", "date": "2018-09-12T21:27:25.241689"},
+ {"id": 615064591, "state": "CANCELED", "date": "2018-10-14T08:21:33.419441"},
+ ],
+ False,
+ ),
+ )
+
+ print(
+ "sort ",
+ sort_by_date(
+ [
+ {"id": 41428829, "state": "EXECUTED", "date": "2019-07-03T18:35:29.512364"},
+ {"id": 939719570, "state": "EXECUTED", "date": "2018-06-30T02:08:58.425572"},
+ {"id": 939719572, "state": "EXECUTED", "date": "2018-06-30T02:08:58.425572"},
+ {"id": 594226727, "state": "CANCELED", "date": "2018-09-12T21:27:25.241689"},
+ {"id": 615064591, "state": "CANCELED", "date": "2018-10-14T08:21:33.419441"},
+ ]
+ ),
+ )
+
+
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/tests/conftest.py b/tests/conftest.py
new file mode 100644
index 0000000..0dae911
--- /dev/null
+++ b/tests/conftest.py
@@ -0,0 +1,19 @@
+from datetime import datetime
+
+import pytest
+
+
+@pytest.fixture
+def error_message() -> str:
+ return "Неверный номер карты!"
+
+
+@pytest.fixture
+def error_data_message() -> str:
+ return "Неверный формат даты!"
+
+
+@pytest.fixture
+def current_data() -> str:
+ now_time = datetime.now()
+ return str(now_time.isoformat())
diff --git a/tests/test_masks.py b/tests/test_masks.py
new file mode 100644
index 0000000..c5b8dbf
--- /dev/null
+++ b/tests/test_masks.py
@@ -0,0 +1,74 @@
+import pytest
+
+from src.masks import get_mask_account, get_mask_card_number
+
+valid_cards = [
+ ("1234567890123456", "1234 56** **** 3456"),
+ ("0000111122223333", "0000 11** **** 3333"),
+ (" 1234 5678 9012 3456 ", "1234 56** **** 3456"),
+ ("1234-5678-9012-3456", "1234 56** **** 3456"),
+ ("Visa 1234 5678 9012 3456", "1234 56** **** 3456"),
+ ("MC-1234-5678-9012-3456", "1234 56** **** 3456"),
+ ("Карта: 1234 5678 9012 3456", "1234 56** **** 3456"),
+ ("Visa Platinum 7000 7122 8960 6361", "7000 71** **** 6361"),
+ ("Maestro 7000792108106361", "7000 79** **** 6361"),
+ ("MasterCard 7158 3007 3472 6758", "7158 30** **** 6758"),
+ ("Счет 1234567890123456", "1234 56** **** 3456"),
+ ("Платежная карта № 1234-5678-9012-3456", "1234 56** **** 3456"),
+]
+
+
+invalid_cards = [
+ "1234",
+ "12345678901234567890",
+ "Card 1234 5678 9012",
+ "Visa 1234abcd5678efgh",
+ "",
+ " ",
+ "Счет без номера",
+ "123456789012345a",
+ "1234 5678 9012 345",
+]
+
+
+valid_accounts = [
+ ("Счет 73654108430535874307", "**4307"),
+ ("Счет 73654108430535874307 ", "**4307"),
+ ("Счет 7365-4108-4305-3587-4307 ", "**4307"),
+ ("Счет 7365 4108 4305 3587 4307", "**4307"),
+]
+
+
+invalid_accounts = [
+ "Счет 736541084305358874307",
+ "Счет 7365410843053588747",
+ "",
+ " ",
+ "Счет без номера",
+ "1234 2345 2345",
+ "12d3 654t 3245 5678 fght",
+]
+
+
+@pytest.mark.parametrize("card_input, expected", valid_cards)
+def test_valid_card_masking(card_input: str, expected: str) -> None:
+ assert get_mask_card_number(card_input) == expected
+
+
+@pytest.mark.parametrize("card_input", invalid_cards)
+def test_invalid_card_errors(card_input: str, error_message: str) -> None:
+ with pytest.raises(ValueError) as exc_info:
+ get_mask_card_number(card_input)
+ assert str(exc_info.value) == error_message
+
+
+@pytest.mark.parametrize("card_input, expected", valid_accounts)
+def test_valid_account_masking(card_input: str, expected: str) -> None:
+ assert get_mask_account(card_input) == expected
+
+
+@pytest.mark.parametrize("card_input", invalid_accounts)
+def test_invalid_account_errors(card_input: str, error_message: str) -> None:
+ with pytest.raises(ValueError) as exc_info:
+ get_mask_account(card_input)
+ assert str(exc_info.value) == error_message
diff --git a/tests/test_processing.py b/tests/test_processing.py
new file mode 100644
index 0000000..3ef5cda
--- /dev/null
+++ b/tests/test_processing.py
@@ -0,0 +1,75 @@
+import pytest
+
+from src.processing import filter_by_state, sort_by_date
+
+list_date = [
+ {"id": 41428829, "state": "EXECUTED", "date": "2019-07-03T18:35:29.512364"},
+ {"id": 939719570, "state": "EXECUTED", "date": "2018-06-30T02:08:58.425572"},
+ {"id": 939719572, "state": "EXECUTED", "date": "2018-06-30T02:08:58.425572"},
+ {"id": 594226727, "state": "CANCELED", "date": "2018-09-12T21:27:25.241689"},
+ {"id": 615064591, "state": "CANCELED", "date": "2018-10-14T08:21:33.419441"},
+]
+
+list_executed = [
+ {"id": 41428829, "state": "EXECUTED", "date": "2019-07-03T18:35:29.512364"},
+ {"id": 939719570, "state": "EXECUTED", "date": "2018-06-30T02:08:58.425572"},
+ {"id": 939719572, "state": "EXECUTED", "date": "2018-06-30T02:08:58.425572"},
+]
+
+list_canceled = [
+ {"id": 594226727, "state": "CANCELED", "date": "2018-09-12T21:27:25.241689"},
+ {"id": 615064591, "state": "CANCELED", "date": "2018-10-14T08:21:33.419441"},
+]
+
+list_empty: list = []
+
+
+list_sorted_false = [
+ {"id": 939719570, "state": "EXECUTED", "date": "2018-06-30T02:08:58.425572"},
+ {"id": 939719572, "state": "EXECUTED", "date": "2018-06-30T02:08:58.425572"},
+ {"id": 594226727, "state": "CANCELED", "date": "2018-09-12T21:27:25.241689"},
+ {"id": 615064591, "state": "CANCELED", "date": "2018-10-14T08:21:33.419441"},
+ {"id": 41428829, "state": "EXECUTED", "date": "2019-07-03T18:35:29.512364"},
+]
+
+
+list_sorted_true = [
+ {"id": 41428829, "state": "EXECUTED", "date": "2019-07-03T18:35:29.512364"},
+ {"id": 615064591, "state": "CANCELED", "date": "2018-10-14T08:21:33.419441"},
+ {"id": 594226727, "state": "CANCELED", "date": "2018-09-12T21:27:25.241689"},
+ {"id": 939719570, "state": "EXECUTED", "date": "2018-06-30T02:08:58.425572"},
+ {"id": 939719572, "state": "EXECUTED", "date": "2018-06-30T02:08:58.425572"},
+]
+
+
+@pytest.mark.parametrize(
+ "date_list, state, expected",
+ [
+ (list_date, "EXECUTED", list_executed),
+ (list_date, "CANCELED", list_canceled),
+ (list_date, "", list_empty),
+ (list_date, "UNKNOW", list_empty),
+ (list_date, None, list_empty),
+ (list_empty, None, list_empty),
+ (list_empty, "EXECUTED", list_empty),
+ (list_empty, "CANCELED", list_empty),
+ ],
+)
+def test_filter_by_state(date_list: list, state: str, expected: list) -> None:
+ """
+ Тестируем функцию filter_by_state
+
+ :param date_list:
+ :param state:
+ :param expected:
+ :return:
+ """
+ assert filter_by_state(date_list, state) == expected
+
+
+@pytest.mark.parametrize(
+ "date_list, ascending, expected",
+ [(list_date, False, list_sorted_false), (list_date, True, list_sorted_true), (list_date, None, list_sorted_false)],
+)
+def test_sort_by_date(date_list: list, ascending: bool, expected: list) -> None:
+ assert sort_by_date(date_list, ascending) == expected
diff --git a/tests/test_widget.py b/tests/test_widget.py
new file mode 100644
index 0000000..f1361c3
--- /dev/null
+++ b/tests/test_widget.py
@@ -0,0 +1,91 @@
+import pytest
+
+from src.widget import get_date, mask_account_card
+
+# Параметры правильных данных карт
+valid_cards = [
+ ("Visa 1234 5678 9012 3456", "Visa 1234 56** **** 3456"),
+ ("MC-1234-5678-9012-3456", "MC 1234 56** **** 3456"),
+ ("Карта: 1234 5678 9012 3456", "Карта: 1234 56** **** 3456"),
+ ("Visa Platinum 7000 7122 8960 6361", "Visa Platinum 7000 71** **** 6361"),
+ ("Maestro 7000792108106361", "Maestro 7000 79** **** 6361"),
+ ("MasterCard 7158 3007 3472 6758", "MasterCard 7158 30** **** 6758"),
+ ("Платежная карта № 1234-5678-9012-3456", "Платежная карта № 1234 56** **** 3456"),
+ ("Счет 73654108430535874307", "Счет **4307"),
+ ("Счет 73654108430535874307 ", "Счет **4307"),
+ ("Счет 7365-4108-4305-3587-4307 ", "Счет **4307"),
+ ("Счет 7365 4108 4305 3587 4307", "Счет **4307"),
+]
+
+
+# Параметры неправильных данных карт
+invalid_cards = [
+ "1234",
+ "12345678901234567890",
+ "Card 1234 5678 9012",
+ "Visa 1234abcd5678efgh",
+ "",
+ " ",
+ "Счет без номера",
+ "123456789012345a",
+ "1234 5678 9012 345",
+ "Счет736541084305358874307",
+ "Счет 7365410843053588747",
+ "",
+ " ",
+ "Счет без номера",
+ "1234 2345 2345",
+ "12d3 654t 3245 5678 fght",
+]
+
+
+# Параметры правильных данных
+valid_dates = [
+ ("2024-03-11T02:26:18.671407", "11.03.2024"),
+ ("2023-12-31T23:59:59.999999", "31.12.2023"),
+ ("2000-01-01T00:00:00.000000", "01.01.2000"),
+ ("1999-02-28T15:30:45.123456", "28.02.1999"),
+ ("2024-02-29T12:00:00.000000", "29.02.2024"),
+]
+
+
+# Параметры неправильных данных
+invalid_dates = [
+ "2024-03-32T00:00:00.000000",
+ "2023-13-01T00:00:00.000000",
+ "2024-03-11 ",
+ "11.03.2024T02:26:18.671407",
+ "2024-03-11T25:00:00.000000",
+ "Hello World!",
+ "2024/03/11T02:26:18.671407",
+]
+
+
+@pytest.mark.parametrize("card_input, expected", valid_cards)
+def test_valid_card_masking(card_input: str, expected: str) -> None:
+ assert mask_account_card(card_input) == expected
+
+
+@pytest.mark.parametrize("card_input", invalid_cards)
+def test_invalid_card_errors(card_input: str, error_message: str) -> None:
+ assert mask_account_card(card_input) == error_message
+
+
+# Тест для правильных данных
+@pytest.mark.parametrize("iso_date, expected", valid_dates)
+def test_valid_dates(iso_date: str, expected: str) -> None:
+ result = get_date(iso_date)
+ assert result == expected
+
+
+# Тест для неправильных данных
+@pytest.mark.parametrize("iso_date", invalid_dates)
+def test_invalid_dates(iso_date: str, error_data_message: str) -> None:
+ assert get_date(iso_date) == error_data_message
+
+
+# Тест для пустой строки
+@pytest.mark.parametrize("iso_date", [""])
+def test_none_input(iso_date: str, error_data_message: str) -> None:
+
+ assert get_date(iso_date) == error_data_message