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)
| 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: |
nothing calls this directly
no test coverage detected