from utils.file_processor import FileProcessor, ProcessorOptions import re from pathlib import Path import sys class GrandfatheredRemovalProcessor(FileProcessor): def __init__(self, options: ProcessorOptions, pattern: str): super().__init__(options) self.pattern = pattern def process_content(self, content: str) -> str: # Remove occurrences of the grandfathered content pattern content = re.sub(self.pattern, '', content) # Normalize whitespace and commas content = re.sub(r'\s+,', ',', content) content = re.sub(r',\s+', ',', content) return re.sub(r'\s+', ' ', content).strip() def main(): target_dir = sys.argv[1] if len(sys.argv) > 1 else '.' options = ProcessorOptions( recursive=True, dry_run=False, file_extensions={'.txt', '.tags'} ) # Define the pattern for grandfathered content (modify as needed) grandfathered_pattern = r'grandfathered_content_pattern' processor = GrandfatheredRemovalProcessor(options, grandfathered_pattern) processor.process_directory(Path(target_dir)) if __name__ == "__main__": main()