Add support for new .toc client version suffixes: MyAddon-BCC.toc, MyAddon-Classic.toc, MyAddon-Mainline.toc.
This commit is contained in:
parent
1f3bbbde28
commit
415041be8d
1 changed files with 12 additions and 2 deletions
|
@ -105,9 +105,11 @@ def find_addon_dirs(path: Path) -> Dict[str, Path]:
|
||||||
addon_dirs = {}
|
addon_dirs = {}
|
||||||
for p in level:
|
for p in level:
|
||||||
tocs = list(p.glob("*.toc"))
|
tocs = list(p.glob("*.toc"))
|
||||||
if any(toc.stem == p.name for toc in tocs):
|
if any(Path(toc_stem(str(toc))).stem == p.name for toc in tocs):
|
||||||
addon_dirs[p.name] = p
|
addon_dirs[p.name] = p
|
||||||
elif len(level) == 1 and len(tocs) == 1:
|
# using the length of the toc_stem set to allow multiple .tocs in the root, as long as they are identically
|
||||||
|
# named when the client version suffix is stripped
|
||||||
|
elif len(level) == 1 and len(set(toc_stem(str(t)) for t in tocs)) == 1:
|
||||||
addon_dirs[tocs[0].stem] = p
|
addon_dirs[tocs[0].stem] = p
|
||||||
if addon_dirs:
|
if addon_dirs:
|
||||||
logger.debug("Found AddOn dirs: %s in '%s'", addon_dirs, path)
|
logger.debug("Found AddOn dirs: %s in '%s'", addon_dirs, path)
|
||||||
|
@ -119,6 +121,14 @@ def find_addon_dirs(path: Path) -> Dict[str, Path]:
|
||||||
raise FileNotFoundError(f"No AddOn dirs found in {path}")
|
raise FileNotFoundError(f"No AddOn dirs found in {path}")
|
||||||
|
|
||||||
|
|
||||||
|
def toc_stem(toc: str):
|
||||||
|
"""
|
||||||
|
Removes AddOn .toc client version suffixes, such as '-Classic.toc' or '-BCC.toc'.
|
||||||
|
See https://github.com/Stanzilla/WoWUIBugs/issues/68#issuecomment-830351390 for more information.
|
||||||
|
"""
|
||||||
|
return re.sub(r"(.*)-(BCC|Classic|Mainline)(\.toc)", r"\1\3", toc)
|
||||||
|
|
||||||
|
|
||||||
def get_valid_dir_filename(s: str) -> str:
|
def get_valid_dir_filename(s: str) -> str:
|
||||||
"""
|
"""
|
||||||
From https://github.com/django/django/blob/master/django/utils/text.py
|
From https://github.com/django/django/blob/master/django/utils/text.py
|
||||||
|
|
Loading…
Reference in a new issue