mirror of
https://github.com/derrod/legendary.git
synced 2024-12-22 17:55:27 +00:00
[lfs/utils] Prevent app name colliding with itself
This commit is contained in:
parent
054a3ea7eb
commit
07ae84c6a0
|
@ -367,9 +367,7 @@ class LGDLFS:
|
||||||
if game.is_dlc:
|
if game.is_dlc:
|
||||||
continue
|
continue
|
||||||
game_folder = game.metadata.get('customAttributes', {}).get('FolderName', {}).get('value', None)
|
game_folder = game.metadata.get('customAttributes', {}).get('FolderName', {}).get('value', None)
|
||||||
_aliases = generate_aliases(game.app_title, game_folder)
|
_aliases = generate_aliases(game.app_title, game_folder=game_folder, app_name=game.app_name)
|
||||||
# include lowercase version of app name in aliases
|
|
||||||
_aliases.append(app_name.lower())
|
|
||||||
for alias in _aliases:
|
for alias in _aliases:
|
||||||
if alias not in aliases:
|
if alias not in aliases:
|
||||||
aliases.add(alias)
|
aliases.add(alias)
|
||||||
|
|
|
@ -43,7 +43,7 @@ def _filter(input):
|
||||||
return ''.join(l for l in input if l in allowed_characters)
|
return ''.join(l for l in input if l in allowed_characters)
|
||||||
|
|
||||||
|
|
||||||
def generate_aliases(game_name, game_folder=None, split_words=True):
|
def generate_aliases(game_name, game_folder=None, split_words=True, app_name=None):
|
||||||
# normalise and split name, then filter for legal characters
|
# normalise and split name, then filter for legal characters
|
||||||
game_parts = [_filter(p) for p in game_name.lower().split()]
|
game_parts = [_filter(p) for p in game_name.lower().split()]
|
||||||
# filter out empty parts
|
# filter out empty parts
|
||||||
|
@ -72,6 +72,9 @@ def generate_aliases(game_name, game_folder=None, split_words=True):
|
||||||
# include folder name for alternative short forms
|
# include folder name for alternative short forms
|
||||||
if game_folder:
|
if game_folder:
|
||||||
_aliases.extend(generate_aliases(game_folder, split_words=False))
|
_aliases.extend(generate_aliases(game_folder, split_words=False))
|
||||||
|
# include lowercase version of app name in aliases
|
||||||
|
if app_name:
|
||||||
|
_aliases.append(app_name.lower())
|
||||||
# include initialisms
|
# include initialisms
|
||||||
if len(game_parts) > 1:
|
if len(game_parts) > 1:
|
||||||
_aliases.append(''.join(p[0] for p in game_parts))
|
_aliases.append(''.join(p[0] for p in game_parts))
|
||||||
|
|
Loading…
Reference in a new issue