Added if checks in the get_project* and get_engine* function to protect against None being returned from get_project_json_data and get_engine_json_data respectively (#1880)

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
main
lumberyard-employee-dm 5 years ago committed by GitHub
parent 71c6b3e506
commit 8592e4fbbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -278,8 +278,10 @@ def get_repos() -> list:
def get_engine_projects() -> list: def get_engine_projects() -> list:
engine_path = get_this_engine_path() engine_path = get_this_engine_path()
engine_object = get_engine_json_data(engine_path=engine_path) engine_object = get_engine_json_data(engine_path=engine_path)
return list(map(lambda rel_path: (pathlib.Path(engine_path) / rel_path).as_posix(), if engine_object:
engine_object['projects'])) if 'projects' in engine_object else [] return list(map(lambda rel_path: (pathlib.Path(engine_path) / rel_path).as_posix(),
engine_object['projects'])) if 'projects' in engine_object else []
return []
def get_engine_gems() -> list: def get_engine_gems() -> list:
@ -289,22 +291,28 @@ def get_engine_gems() -> list:
def get_engine_external_subdirectories() -> list: def get_engine_external_subdirectories() -> list:
engine_path = get_this_engine_path() engine_path = get_this_engine_path()
engine_object = get_engine_json_data(engine_path=engine_path) engine_object = get_engine_json_data(engine_path=engine_path)
return list(map(lambda rel_path: (pathlib.Path(engine_path) / rel_path).as_posix(), if engine_object:
engine_object['external_subdirectories'])) if 'external_subdirectories' in engine_object else [] return list(map(lambda rel_path: (pathlib.Path(engine_path) / rel_path).as_posix(),
engine_object['external_subdirectories'])) if 'external_subdirectories' in engine_object else []
return []
def get_engine_templates() -> list: def get_engine_templates() -> list:
engine_path = get_this_engine_path() engine_path = get_this_engine_path()
engine_object = get_engine_json_data(engine_path=engine_path) engine_object = get_engine_json_data(engine_path=engine_path)
return list(map(lambda rel_path: (pathlib.Path(engine_path) / rel_path).as_posix(), if engine_object:
engine_object['templates'])) return list(map(lambda rel_path: (pathlib.Path(engine_path) / rel_path).as_posix(),
engine_object['templates'])) if 'templates' in engine_object else []
return []
def get_engine_restricted() -> list: def get_engine_restricted() -> list:
engine_path = get_this_engine_path() engine_path = get_this_engine_path()
engine_object = get_engine_json_data(engine_path=engine_path) engine_object = get_engine_json_data(engine_path=engine_path)
return list(map(lambda rel_path: (pathlib.Path(engine_path) / rel_path).as_posix(), if engine_object:
engine_object['restricted'])) if 'restricted' in engine_object else [] return list(map(lambda rel_path: (pathlib.Path(engine_path) / rel_path).as_posix(),
engine_object['restricted'])) if 'restricted' in engine_object else []
return []
# project.json queries # project.json queries
@ -314,20 +322,26 @@ def get_project_gems(project_path: pathlib.Path) -> list:
def get_project_external_subdirectories(project_path: pathlib.Path) -> list: def get_project_external_subdirectories(project_path: pathlib.Path) -> list:
project_object = get_project_json_data(project_path=project_path) project_object = get_project_json_data(project_path=project_path)
return list(map(lambda rel_path: (pathlib.Path(project_path) / rel_path).as_posix(), if project_object:
project_object['external_subdirectories'])) if 'external_subdirectories' in project_object else [] return list(map(lambda rel_path: (pathlib.Path(project_path) / rel_path).as_posix(),
project_object['external_subdirectories'])) if 'external_subdirectories' in project_object else []
return []
def get_project_templates(project_path: pathlib.Path) -> list: def get_project_templates(project_path: pathlib.Path) -> list:
project_object = get_project_json_data(project_path=project_path) project_object = get_project_json_data(project_path=project_path)
return list(map(lambda rel_path: (pathlib.Path(project_path) / rel_path).as_posix(), if project_object:
project_object['templates'])) return list(map(lambda rel_path: (pathlib.Path(project_path) / rel_path).as_posix(),
project_object['templates'])) if 'templates' in project_object else []
return []
def get_project_restricted(project_path: pathlib.Path) -> list: def get_project_restricted(project_path: pathlib.Path) -> list:
project_object = get_project_json_data(project_path=project_path) project_object = get_project_json_data(project_path=project_path)
return list(map(lambda rel_path: (pathlib.Path(project_path) / rel_path).as_posix(), if project_object:
project_object['restricted'])) if 'restricted' in project_object else [] return list(map(lambda rel_path: (pathlib.Path(project_path) / rel_path).as_posix(),
project_object['restricted'])) if 'restricted' in project_object else []
return []
# Combined manifest queries # Combined manifest queries

Loading…
Cancel
Save