|
|
|
|
@ -354,7 +354,7 @@ def get_all_templates(project_path: pathlib.Path = None) -> list:
|
|
|
|
|
return list(dict.fromkeys(templates_data))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_all_restricted() -> list:
|
|
|
|
|
def get_all_restricted(project_path: pathlib.Path = None) -> list:
|
|
|
|
|
restricted_data = get_restricted()
|
|
|
|
|
restricted_data.extend(get_engine_restricted())
|
|
|
|
|
if project_path:
|
|
|
|
|
@ -488,14 +488,14 @@ def get_project_json_data(project_name: str = None,
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_gem_json_data(gem_name: str = None,
|
|
|
|
|
gem_path: str or pathlib.Path = None) -> dict or None:
|
|
|
|
|
def get_gem_json_data(gem_name: str = None, gem_path: str or pathlib.Path = None,
|
|
|
|
|
project_path: pathlib.Path = None) -> dict or None:
|
|
|
|
|
if not gem_name and not gem_path:
|
|
|
|
|
logger.error('Must specify either a Gem name or Gem Path.')
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
if gem_name and not gem_path:
|
|
|
|
|
gem_path = get_registered(gem_name=gem_name)
|
|
|
|
|
gem_path = get_registered(gem_name=gem_name, project_path=project_path)
|
|
|
|
|
|
|
|
|
|
if not gem_path:
|
|
|
|
|
logger.error(f'Gem Path {gem_path} has not been registered.')
|
|
|
|
|
@ -521,14 +521,14 @@ def get_gem_json_data(gem_name: str = None,
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_template_json_data(template_name: str = None,
|
|
|
|
|
template_path: str or pathlib.Path = None) -> dict or None:
|
|
|
|
|
def get_template_json_data(template_name: str = None, template_path: str or pathlib.Path = None,
|
|
|
|
|
project_path: pathlib.Path = None) -> dict or None:
|
|
|
|
|
if not template_name and not template_path:
|
|
|
|
|
logger.error('Must specify either a Template name or Template Path.')
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
if template_name and not template_path:
|
|
|
|
|
template_path = get_registered(template_name=template_name)
|
|
|
|
|
template_path = get_registered(template_name=template_name, project_path=project_path)
|
|
|
|
|
|
|
|
|
|
if not template_path:
|
|
|
|
|
logger.error(f'Template Path {template_path} has not been registered.')
|
|
|
|
|
@ -554,14 +554,14 @@ def get_template_json_data(template_name: str = None,
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_restricted_json_data(restricted_name: str = None,
|
|
|
|
|
restricted_path: str or pathlib.Path = None) -> dict or None:
|
|
|
|
|
def get_restricted_json_data(restricted_name: str = None, restricted_path: str or pathlib.Path = None,
|
|
|
|
|
project_path: pathlib.Path = None) -> dict or None:
|
|
|
|
|
if not restricted_name and not restricted_path:
|
|
|
|
|
logger.error('Must specify either a Restricted name or Restricted Path.')
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
if restricted_name and not restricted_path:
|
|
|
|
|
restricted_path = get_registered(restricted_name=restricted_name)
|
|
|
|
|
restricted_path = get_registered(restricted_name=restricted_name, project_path=project_path)
|
|
|
|
|
|
|
|
|
|
if not restricted_path:
|
|
|
|
|
logger.error(f'Restricted Path {restricted_path} has not been registered.')
|
|
|
|
|
@ -593,7 +593,32 @@ def get_registered(engine_name: str = None,
|
|
|
|
|
template_name: str = None,
|
|
|
|
|
default_folder: str = None,
|
|
|
|
|
repo_name: str = None,
|
|
|
|
|
restricted_name: str = None) -> pathlib.Path or None:
|
|
|
|
|
restricted_name: str = None,
|
|
|
|
|
project_path: pathlib.Path = None) -> pathlib.Path or None:
|
|
|
|
|
"""
|
|
|
|
|
Looks up a registered entry in either the ~/.o3de/o3de_manifest.json, <this-engine-root>/engine.json
|
|
|
|
|
or the <project-path>/project.json (if the project_path parameter is supplied)
|
|
|
|
|
|
|
|
|
|
:param engine_name: Name of a registered engine to lookup in the ~/.o3de/o3de_manifest.json file
|
|
|
|
|
:param project_name: Name of a project to lookup in either the ~/.o3de/o3de_manifest.json or
|
|
|
|
|
<this-engine-root>/engine.json file
|
|
|
|
|
:param gem_name: Name of a gem to lookup in either the ~/.o3de/o3de_manifest.json, <this-engine-root>/engine.json
|
|
|
|
|
or <project-path>/project.json. NOTE: The project_path parameter must be supplied to lookup the registration
|
|
|
|
|
with the project.json
|
|
|
|
|
:param template_name: Name of a template to lookup in either the ~/.o3de/o3de_manifest.json, <this-engine-root>/engine.json
|
|
|
|
|
or <project-path>/project.json. NOTE: The project_path parameter must be supplied to lookup the registration
|
|
|
|
|
with the project.json
|
|
|
|
|
:param repo_name: Name of a repo to lookup in the ~/.o3de/o3de_manifest.json
|
|
|
|
|
:param default_folder: Type of "default" folder to lookup in the ~/.o3de/o3de_manifest.json
|
|
|
|
|
Valid values are "engines", "projects", "gems", "templates,", "restricted"
|
|
|
|
|
:param restricted_name: Name of a restricted directory object to lookup in either the ~/.o3de/o3de_manifest.json,
|
|
|
|
|
<this-engine-root>/engine.json or <project-path>/project.json.
|
|
|
|
|
NOTE: The project_path parameter must be supplied to lookup the registration with the project.json
|
|
|
|
|
:param project_path: Path to project root, which is used to examined the project.json file in order to
|
|
|
|
|
query either gems, templates or restricted directories registered with the project
|
|
|
|
|
|
|
|
|
|
:return path value associated with the registered object name if found. Otherwise None is returned
|
|
|
|
|
"""
|
|
|
|
|
json_data = load_o3de_manifest()
|
|
|
|
|
|
|
|
|
|
# check global first then this engine
|
|
|
|
|
@ -627,7 +652,7 @@ def get_registered(engine_name: str = None,
|
|
|
|
|
return project_path
|
|
|
|
|
|
|
|
|
|
elif isinstance(gem_name, str):
|
|
|
|
|
gems = get_all_gems()
|
|
|
|
|
gems = get_all_gems(project_path)
|
|
|
|
|
for gem_path in gems:
|
|
|
|
|
gem_path = pathlib.Path(gem_path).resolve()
|
|
|
|
|
gem_json = gem_path / 'gem.json'
|
|
|
|
|
@ -642,7 +667,7 @@ def get_registered(engine_name: str = None,
|
|
|
|
|
return gem_path
|
|
|
|
|
|
|
|
|
|
elif isinstance(template_name, str):
|
|
|
|
|
templates = get_all_templates()
|
|
|
|
|
templates = get_all_templates(project_path)
|
|
|
|
|
for template_path in templates:
|
|
|
|
|
template_path = pathlib.Path(template_path).resolve()
|
|
|
|
|
template_json = template_path / 'template.json'
|
|
|
|
|
@ -657,7 +682,7 @@ def get_registered(engine_name: str = None,
|
|
|
|
|
return template_path
|
|
|
|
|
|
|
|
|
|
elif isinstance(restricted_name, str):
|
|
|
|
|
restricted = get_all_restricted()
|
|
|
|
|
restricted = get_all_restricted(project_path)
|
|
|
|
|
for restricted_path in restricted:
|
|
|
|
|
restricted_path = pathlib.Path(restricted_path).resolve()
|
|
|
|
|
restricted_json = restricted_path / 'restricted.json'
|
|
|
|
|
|