Skip to content

Commit

Permalink
Update ptbr.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jnackmclain committed Jan 27, 2025
1 parent f6603de commit 5a320b4
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions dependencies/python/ptbr.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
#!/usr/bin/env python3

import re
import os

# Resolve the file path and print the current working directory
file_path = os.path.abspath("_ark/dx/macros/dx_macros.dta")

import os
print("Resolved File Path:", file_path)
print("Current Working Directory:", os.getcwd())

# Read the entire file
with open(file_path, "r") as f:
# Check if the file exists
if not os.path.exists(file_path):
raise FileNotFoundError(f"File not found: {file_path}")

# Read the entire file with explicit UTF-8 encoding
with open(file_path, "r", encoding="utf-8") as f:
content = f.read()

# Debug: Print the original content
print("Original Content:\n", content)

# Replace the line that begins with optional whitespace, then a semicolon, then "#define DX_PTBR (1)"
content = re.sub(r'(?m)^[ \t]*;#define DX_PTBR \(1\)', '#define DX_PTBR (1)', content)
# Handles both Linux (\n) and Windows (\r\n) line endings
content = re.sub(r'(?m)^[ \t]*;#define DX_PTBR \(1\)\r?$', '#define DX_PTBR (1)', content)

# Debug: Print the modified content
print("Modified Content:\n", content)

# Write back the modified content
with open(file_path, "w") as f:
# Write back the modified content with explicit UTF-8 encoding
with open(file_path, "w", encoding="utf-8") as f:
f.write(content)

print("Uncommenting completed successfully!")

0 comments on commit 5a320b4

Please sign in to comment.