-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6603de
commit 5a320b4
Showing
1 changed file
with
21 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
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!") |