-
Notifications
You must be signed in to change notification settings - Fork 9
/
h_server_fix.py
110 lines (91 loc) · 2.58 KB
/
h_server_fix.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import re
from c_path import Directories, Files
SERVERS = {
"0x06": "Lordaeron",
"0x07": "Icecrown",
"0x0D": "Frostmourne3",
"0x0C": "Frostmourne2",
"0x0A": "Blackrock",
"0x0E": "Onyxia",
}
SERVERS_WC = {
"WoW-Circle-x100": "6",
"WoW-Circle-x1": "2",
"WoW-Circle-x5": "1",
"WoW-Circle-Fun": "13",
}
SERVERS_NAMES = set(SERVERS.values())
class ServerID:
__slots__ = "name", "re_string"
def __init__(self, name: str, re_string: str) -> None:
self.name = name
self.re_string = re_string
@property
def no_space(self):
return self.name.replace(" ", "-")
@property
def html(self):
return self.no_space.lower()
def __str__(self):
return ' | '.join((
self.name,
self.re_string,
self.no_space,
self.html,
))
__repr__ = __str__
SERVERS_OTHER = [
ServerID("Rising Gods", "(risin.*?god)"),
ServerID("WoW Circle", "(circle)"),
ServerID("Whitemane-PTR", "(whitemane.*?ptr)"),
ServerID("Whitemane-Frostmourne", "(frostmo)"),
ServerID("Whitemane-Frostmourne", "(whitema)"),
ServerID("WoW-Mania", "(mania)"),
ServerID("ChromieCraft", "(chromie.*?craft)"),
ServerID("EzWoW", "(ez.*?wow)"),
ServerID("NaerZone", "(naer.*?zone)"),
ServerID("Way of Elendil", "(way.*?elendil)"),
ServerID("WoW Brasil", "(wow.*?brasil)"),
ServerID("Aequitas", "(aequitas)"),
ServerID("Everlook", "(everlook)"),
ServerID("UltimoWoW", "(ultim.*wow)"),
ServerID("UltimoWoW", "(benn?u)"),
# ServerName("", ""),
]
def server_cnv(server: str):
if not server:
return ""
if server in SERVERS_NAMES:
return server
_server_l = server.lower()
for _server in SERVERS_OTHER:
if re.findall(_server.re_string, _server_l):
return _server.no_space
return server.replace(" ", "-")
@Directories.top.cache_until_new_self
def _get_servers(folder):
s = set((
file_path.stem
for file_path in folder.iterdir()
if file_path.suffix == ".db"
))
SERVERS_MAIN = Files.server_main.json_cached_ignore_error()
new = sorted(s - set(SERVERS_MAIN))
return SERVERS_MAIN + new
def get_servers() -> list[str]:
return _get_servers()
def test1():
re_test = [
"Lordaeron",
"Wow Circle 3.3.5a x5",
"rIsing godSs",
"risINGg godds",
"Way-of-Elendil",
"Benu",
"Bennu",
"ULTIMAWOW",
]
for s in re_test:
print(server_cnv(s))
if __name__ == "__main__":
test1()