Skip to content

Commit 8b307d6

Browse files
committed
fix autogen cmd
1 parent 93bdcdb commit 8b307d6

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

src/aaz_dev/command/api/_cmds.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def generate_command_models_from_swagger(swagger_tag, workspace_path=None):
112112
"id": resource_id
113113
})
114114

115-
mod_names = Config.DEFAULT_SWAGGER_MODULE.split('/')
115+
mod_names = Config.DEFAULT_SWAGGER_MODULE
116116
ws = WorkspaceManager.new(
117117
name=Config.DEFAULT_SWAGGER_MODULE,
118118
plane=Config.DEFAULT_PLANE,

src/aaz_dev/command/controller/workspace_manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,8 @@ def create_cfg_editor(self, auth, templates=None, cloud_medadata=None, arm_resou
12431243
def load_client_cfg_editor(self, reload=False):
12441244
if not reload and self._client_cfg_editor:
12451245
return self._client_cfg_editor
1246+
if self.is_in_memory:
1247+
return None
12461248
assert not self.is_in_memory
12471249
try:
12481250
self._client_cfg_editor = WorkspaceClientCfgEditor.load_client_cfg(self.folder)

src/aaz_dev/swagger/model/specs/_resource_provider.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def tags(self):
8686
self._tags = self._parse_readme_input_file_tags()
8787
return self._tags
8888

89-
def _parse_readme_input_file_tags(self):
89+
def _parse_readme_input_file_tags_v0(self):
9090
tags = {}
9191
if not self._readme_paths:
9292
return tags
@@ -133,6 +133,43 @@ def _parse_readme_input_file_tags(self):
133133
tags = OrderedDict(tags)
134134
return tags
135135

136+
def _parse_readme_input_file_tags(self):
137+
tags = {}
138+
if not self._readme_paths:
139+
return tags
140+
141+
for readme_path in self._readme_paths:
142+
with open(readme_path, 'r', encoding='utf-8') as f:
143+
readme = f.read()
144+
145+
pattern = re.compile(r'yaml\s*\$\(\s*tag\s*\)\s*==\s*\'([^\']+)\'\s*input-file:\s*((?:\s*- [^\n]+\s*)+)\s*',
146+
flags=re.DOTALL)
147+
for piece in pattern.finditer(readme):
148+
tag = piece[1].strip()
149+
input_files = piece[2].splitlines()
150+
files = []
151+
for i_file in input_files:
152+
file_path = i_file.strip().lstrip('-').strip()
153+
file_path = file_path.replace('$(this-folder)/', '')
154+
file_path = os.path.join(os.path.dirname(readme_path), *file_path.split('/'))
155+
if not os.path.isfile(file_path):
156+
logger.warning(f'FileNotExist: {self} : {file_path}')
157+
continue
158+
files.append(file_path)
159+
160+
if len(files):
161+
if tag is None:
162+
tag = ''
163+
tag = OpenAPIResourceProviderTag(tag.strip(), self)
164+
if tag not in tags:
165+
tags[tag] = set()
166+
tags[tag] = tags[tag].union(files)
167+
168+
tags = [*tags.items()]
169+
tags.sort(key=lambda item: item[0].date, reverse=True)
170+
tags = OrderedDict(tags)
171+
return tags
172+
136173
def _fetch_latest_tag(self, file_path):
137174
for tag, file_set in self.tags.items():
138175
if file_path in file_set:

0 commit comments

Comments
 (0)