From 168fb5f99bb05fbe29c30d7672e278f5bf6ad172 Mon Sep 17 00:00:00 2001 From: Lev Rusanov <30170278+JDM170@users.noreply.github.com> Date: Mon, 29 Aug 2022 10:59:48 +0700 Subject: [PATCH] Testing git modules system Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com> --- .gitmodules | 3 +++ m_match_name | 1 + main.py | 5 ++--- match_name.py | 26 -------------------------- 4 files changed, 6 insertions(+), 29 deletions(-) create mode 100644 .gitmodules create mode 160000 m_match_name delete mode 100644 match_name.py diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..840a0fb --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "m_match_name"] + path = m_match_name + url = https://github.com/JDM170/m_match_name diff --git a/m_match_name b/m_match_name new file mode 160000 index 0000000..c57718a --- /dev/null +++ b/m_match_name @@ -0,0 +1 @@ +Subproject commit c57718af7ed72eb548d7918eb35beb6f82ebb6ec diff --git a/main.py b/main.py index 2ff15af..ef407a5 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,7 @@ # path.append(getcwd()) from sys import exit, argv -from match_name import MatchIO +from m_match_name.main import MatchIO import subprocess from json import loads from datetime import datetime @@ -29,7 +29,7 @@ def timedelta_to_string(delta, pattern): def main(): global is_debug pc_name = input("\nВведите имя ПК (пр. R54-630300THE01, Ctrl+C для выхода):\n> ").strip() - f_pc_name = matchio.check_arm_name(pc_name) + f_pc_name = MatchIO().check_pc_name(pc_name) if f_pc_name: # C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe # or @@ -62,7 +62,6 @@ if __name__ == '__main__': if len(argv) > 1: is_debug = argv[1].strip() == "debug" # is_debug = argv[1].strip() == "debug" if len(argv) > 1 - matchio = MatchIO() main() except KeyboardInterrupt: exit() diff --git a/match_name.py b/match_name.py deleted file mode 100644 index 242de85..0000000 --- a/match_name.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -from re import match - -# Список выражений по которым проводится проверка -# По дефолту стоит регион R54, индекс 630300 -default_expr_list = [ - [r"^[a-zA-Z]+\d+$", "R54-630300"], # THE01 - [r"^\d+[a-zA-Z]+\d+$", "R54-"], # 630300THE01 - [r"^[rR]\d*[-]\d+[a-zA-Z]+\d+$", ""] # R54-630300THE01 -] - - -class MatchIO: - def __init__(self, expr_list=None): - self.expr_list = expr_list is None and default_expr_list or expr_list - - def check_arm_name(self, pc_name): - for r in self.expr_list: - if match(r[0], pc_name): - pc_name = "{}{}".format(r[1], pc_name) - break - if match(self.expr_list[2][0], pc_name): - return pc_name - return False