mirror of
https://github.com/JDM170/m_match_name
synced 2025-12-10 05:57:21 +07:00
Initial commit
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*__pycache__
|
||||
2
__init__.py
Normal file
2
__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
26
main.py
Normal file
26
main.py
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/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_pc_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
|
||||
Reference in New Issue
Block a user