mirror of
https://github.com/JDM170/show_comp_uptime
synced 2024-10-25 13:44:29 +07:00
Update
This commit is contained in:
26
match_name.py
Normal file
26
match_name.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_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
|
||||
Reference in New Issue
Block a user