MCPcopy Create free account
hub / github.com/BUPT-GAMMA/MASFactory / _get_codes

Method _get_codes

applications/chatdev/chatdev/codes.py:148–171  ·  view source on GitHub ↗

Retrieves all code content in a structured list format. Returns: List of code file information, each item is a dictionary with filename, language, docstring, and code

(self)

Source from the content-addressed store, hash-verified

146 log_visualize(log_git_info)
147
148 def _get_codes(self) -> list:
149 """
150 Retrieves all code content in a structured list format.
151 Returns:
152 List of code file information, each item is a dictionary with filename, language, docstring, and code
153 """
154 codes_list = []
155 for filename in self.codebooks.keys():
156 language = "python" if filename.endswith(".py") else filename.split(".")[-1]
157 code_content = self.codebooks[filename]
158 docstring = ""
159 if language == "python":
160 docstring_match = re.search(r'^\s*["\'"]{3}(.*?)["\'"]{3}', code_content, re.DOTALL | re.MULTILINE)
161 if docstring_match:
162 docstring = docstring_match.group(1).strip()
163
164 codes_list.append({
165 "filename": filename,
166 "language": language,
167 "docstring": docstring,
168 "code": code_content
169 })
170
171 return codes_list
172
173 def _load_from_hardware(self, directory) -> None:
174 """

Callers 2

update_and_rewriteFunction · 0.45

Calls 1

keysMethod · 0.80

Tested by

no test coverage detected