mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-26 10:16:34 +00:00
14bf3c81b4
Add wait until blessing stable function;
19 lines
601 B
Python
19 lines
601 B
Python
import re
|
||
|
||
REGEX_PUNCTUATION = re.compile(r'[ ,.\'"“”,。::!!??·•—/()()「」『』【】《》]')
|
||
|
||
|
||
def parse_name(n):
|
||
n = REGEX_PUNCTUATION.sub('', str(n)).lower()
|
||
return n
|
||
|
||
|
||
def get_regex_from_keyword_name(keyword, attr_name):
|
||
string = ""
|
||
for instance in keyword.instances.values():
|
||
if hasattr(instance, attr_name):
|
||
for name in instance.__getattribute__(attr_name):
|
||
string += f"{name}|"
|
||
# some pattern contain each other, make sure each pattern end with "-" or the end of string
|
||
return f"(?:({string[:-1]})(?:-|$))?"
|