Created
          September 3, 2025 09:54 
        
      - 
      
 - 
        
Save xtqqczze/3fe20c0cc5aefc3b53aed69a38461334 to your computer and use it in GitHub Desktop.  
    This file was generated by ChatGPT on 2025-09-03
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import os | |
| import pathlib | |
| def ensure_final_newline_in_resx(root_dir="."): | |
| """ | |
| Ensures that all .resx files under root_dir end with exactly one newline. | |
| """ | |
| root = pathlib.Path(root_dir) | |
| resx_files = list(root.rglob("*.resx")) | |
| for file in resx_files: | |
| with open(file, "rb") as f: | |
| content = f.read() | |
| # Normalize line endings to LF for check | |
| text = content.decode("utf-8", errors="ignore") | |
| # Strip all trailing newlines, then add exactly one | |
| fixed = text.rstrip("\r\n") + "\n" | |
| if text != fixed: | |
| with open(file, "w", encoding="utf-8", newline="\n") as f: | |
| f.write(fixed) | |
| print(f"Fixed: {file}") | |
| else: | |
| print(f"OK: {file}") | |
| if __name__ == "__main__": | |
| ensure_final_newline_in_resx(".") | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment