[lfs/utils] Prevent app name colliding with itself

This commit is contained in:
derrod 2021-10-12 15:00:11 +02:00
parent 054a3ea7eb
commit 07ae84c6a0
2 changed files with 5 additions and 4 deletions

View file

@ -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)

View file

@ -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))