Skip to content

Commit

Permalink
Merge pull request #268 from necusjz/add-verification-log
Browse files Browse the repository at this point in the history
Add log information for aaz verification
  • Loading branch information
necusjz committed Jul 19, 2023
2 parents 08efb02 + 9305f5e commit 3a9c481
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/aaz_dev/command/api/_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ def generate_command_models_from_swagger(swagger_tag, workspace_path=None):
help="Path of `aaz` repository."
)
def verify():
def verify_command(cmd_path, node):
with open(cmd_path, "r") as f:
cmd_content = f.read()
def verify_command(file_path, node):
with open(file_path, "r") as fp:
content = fp.read()

paths = re.findall(r"]\(([^)]+)\)", cmd_content)
paths = re.findall(r"]\(([^)]+)\)", content)
for path in paths:
json_path = os.path.join(Config.AAZ_PATH, os.path.splitext(path)[0][1:] + ".json")
json_path = os.path.normpath(json_path)
Expand All @@ -187,7 +187,7 @@ def verify_command(cmd_path, node):
model_set.add(json_path)

tmpl = get_templates()["command"]
if not tmpl.render(command=node) == cmd_content:
if not tmpl.render(command=node) == content:
raise Exception(f"{file_path} cannot be rendered correctly.")

model_set = set()
Expand All @@ -196,6 +196,7 @@ def verify_command(cmd_path, node):

while stack:
curr_path, curr_node = stack.pop()
logger.info(f"Checking {curr_path}")
if os.path.isdir(curr_path):
readme_path = os.path.join(curr_path, "readme.md")
if not os.path.exists(readme_path):
Expand Down

0 comments on commit 3a9c481

Please sign in to comment.