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

Method process_code_item

applications/chatdev_lite/chatdev/codes.py:40–56  ·  view source on GitHub ↗

Processes a single code dictionary item, extracting filename and code, and storing them in codebooks. Args: item_dict: Dictionary containing filename and code

(item_dict)

Source from the content-addressed store, hash-verified

38 return file_name
39
40 def process_code_item(item_dict):
41 """
42 Processes a single code dictionary item, extracting filename and code, and storing them in codebooks.
43 Args:
44 item_dict: Dictionary containing filename and code
45 """
46 filename = item_dict.get("filename", "").lower()
47 code = item_dict.get("code", "")
48 # If code contains __main__, set filename as main.py
49 if "__main__" in code:
50 filename = "main.py"
51 # If filename is not provided, try extracting it from code
52 if filename == "":
53 filename = extract_filename_from_code(code)
54 assert filename != "", "Filename extraction failed"
55 if filename and code:
56 self.codebooks[filename] = self._format_code(code)
57
58 # Parse and store the generated code if content is provided
59 if generated_content:

Callers

nothing calls this directly

Calls 1

_format_codeMethod · 0.95

Tested by

no test coverage detected