' in XML files."""
+ # Filter files to only XML files
+ files = [file for file in file_manager if file.path.suffix == ".xml"]
+ if not files:
+ logger.info("No XML files found to process")
+ return
+
+ # Regex pattern to match
and its content
+ chatter_re = re.compile(
+ r"""
+
# Opening div with class="oe_chatter"
+ .*? # Any content (non-greedy)
+
# Closing div
+ """,
+ re.VERBOSE | re.DOTALL,
+ ) # DOTALL allows . to match newlines
+
+ # Process each file
+ for fileno, file in enumerate(files, start=1):
+ content = file.content
+
+ # Check if the pattern exists in the file
+ if not chatter_re.search(content):
+ continue
+
+ # Use BeautifulSoup for precise replacement
+ soup = bs(content, "xml")
+ chatter_divs = soup.select("div.oe_chatter")
+
+ if not chatter_divs:
+ logger.debug(f"No
found in {file.path}")
+ continue
+
+ # Replace each
with
+ for div in chatter_divs:
+ new_tag = soup.new_tag("chatter")
+ div.replace_with(new_tag)
+
+ # Update file content
+ file.content = str(soup)
+ logger.info(f"Replaced chatter in {file.path}")
+ file_manager.print_progress(fileno, len(files))