Add the ability to remove tags. Updated some descriptions, and updated some log messages to include parameters.
This commit is contained in:
@@ -13,12 +13,13 @@ logging.basicConfig()
|
||||
def get_project_props(name: str = None, path: pathlib.Path = None) -> dict:
|
||||
proj_json = manifest.get_project_json_data(project_name=name, project_path=path)
|
||||
if not proj_json:
|
||||
logger.error('Could not retrieve project.json file')
|
||||
param = name if name else path
|
||||
logger.error(f'Could not retrieve project.json file for {param}')
|
||||
return None
|
||||
return proj_json
|
||||
|
||||
def edit_project_props(proj_path, proj_name, new_origin, new_display,
|
||||
new_summary, new_icon, new_tag) -> int:
|
||||
new_summary, new_icon, new_tag, remove_tag) -> int:
|
||||
proj_json = get_project_props(proj_name, proj_path)
|
||||
|
||||
if not proj_json:
|
||||
@@ -36,6 +37,14 @@ def edit_project_props(proj_path, proj_name, new_origin, new_display,
|
||||
if 'user_tags' not in proj_json:
|
||||
proj_json['user_tags'] = []
|
||||
proj_json['user_tags'].append(new_tag)
|
||||
if remove_tag:
|
||||
if 'user_tags' in proj_json:
|
||||
if remove_tag in proj_json['user_tags']:
|
||||
proj_json['user_tags'].remove(remove_tag)
|
||||
else:
|
||||
logger.warn(f'{remove_tag} not found in user_tags for removal.')
|
||||
else:
|
||||
logger.warn(f'user_tags property not found for removal of tag {remove_tag}.')
|
||||
|
||||
manifest.save_o3de_manifest(proj_json, pathlib.Path(proj_path) / 'project.json')
|
||||
return 0
|
||||
@@ -47,7 +56,8 @@ def _edit_project_props(args: argparse) -> int:
|
||||
args.project_display,
|
||||
args.project_summary,
|
||||
args.project_icon,
|
||||
args.project_tag)
|
||||
args.project_tag,
|
||||
args.remove_tag)
|
||||
|
||||
def add_parser_args(parser):
|
||||
group = parser.add_mutually_exclusive_group(required=True)
|
||||
@@ -65,7 +75,9 @@ def add_parser_args(parser):
|
||||
group.add_argument('-pi', '--project-icon', type=str, required=False,
|
||||
help='Sets the path to the projects icon resource.')
|
||||
group.add_argument('-pt', '--project-tag', type=str, required=False,
|
||||
help='Adds a tag to canonical user tags. These tags are intended for documentation and filtering.')
|
||||
help='Adds a tag to user tags. These tags are intended for documentation and filtering.')
|
||||
group.add_argument('-rt', '--remove-tag', type=str, required=False,
|
||||
help='Removes a tag from user tags. These tags are intended for documentation and filtering.')
|
||||
parser.set_defaults(func=_edit_project_props)
|
||||
|
||||
def add_args(subparsers) -> None:
|
||||
|
||||
Reference in New Issue
Block a user