From 607f32fae6384bdb655a466a147194477cd706e0 Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Thu, 10 Jun 2021 13:34:16 -0700 Subject: [PATCH] No need to check if the first character is a number. This is already validated before. --- scripts/o3de/o3de/engine_template.py | 4 ++++ scripts/o3de/o3de/utils.py | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/o3de/o3de/engine_template.py b/scripts/o3de/o3de/engine_template.py index 05d6c5f8b9..06e34cc449 100755 --- a/scripts/o3de/o3de/engine_template.py +++ b/scripts/o3de/o3de/engine_template.py @@ -1894,6 +1894,10 @@ def create_gem(gem_path: str, # gem name is now the last component of the gem_path gem_name = os.path.basename(gem_path) + if not utils.validate_identifier(gem_name): + logger.error(f'Gem name must be fewer than 64 characters, contain only alphanumeric, "_" or "-" characters, and start with a letter. {gem_name}') + return 1 + # gem name cannot be the same as a restricted platform name if gem_name in restricted_platforms: logger.error(f'Gem path cannot be a restricted name. {gem_name}') diff --git a/scripts/o3de/o3de/utils.py b/scripts/o3de/o3de/utils.py index 6bb536f0fd..11c668a37b 100755 --- a/scripts/o3de/o3de/utils.py +++ b/scripts/o3de/o3de/utils.py @@ -46,9 +46,6 @@ def sanitize_identifier_for_cpp(identifier: str) -> str: return '' sanitized_identifier = list(identifier) - if not (sanitized_identifier[0].isalpha() or sanitized_identifier[0] == '_'): - sanitized_identifier.insert(0, '_') - for index, character in enumerate(sanitized_identifier): if not (character.isalnum() or character == '_'): sanitized_identifier[index] = '_'