-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Various fixes #355
Various fixes #355
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,14 +212,13 @@ def escape_specials(self, s): | |
return s | ||
|
||
def replace_file_content(self, message, file_path, new_content): | ||
escaped_file_path = re.escape(file_path) | ||
|
||
pattern = rf'\*\*{escaped_file_path}\*\*:\n```\n(.*?)\n```' | ||
pattern = rf'\*\*{re.escape(file_path)}\*\*:\n```\n(.*?)\n```' | ||
|
||
# Escape special characters in new_content for the sake of regex replacement | ||
new_content_escaped = self.escape_specials(new_content) | ||
file_path_escaped = self.escape_specials(file_path) | ||
|
||
new_section_content = f'**{file_path}**\n```\n{new_content_escaped}\n```' | ||
new_section_content = f'**{file_path_escaped}**\n```\n{new_content_escaped}\n```' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Windows paths have plenty of occurrences of |
||
|
||
updated_message, num_replacements = re.subn(pattern, new_section_content, message, flags=re.DOTALL) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,11 @@ def setup_logger(): | |
log_format = "%(asctime)s [%(filename)s:%(lineno)s - %(funcName)20s() ] %(levelname)s: %(message)s" | ||
|
||
# Create a log handler for file output | ||
file_handler = logging.FileHandler(filename=os.path.join(os.path.dirname(__file__), 'debug.log'), mode='w') | ||
file_handler = logging.FileHandler( | ||
filename=os.path.join(os.path.dirname(__file__), 'debug.log'), | ||
mode='w', | ||
encoding='utf-8', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding encoding so logging doesn't crash on Windows when there are characters which don't fit into whatever code page is active by default. |
||
) | ||
|
||
# Apply the custom format to the handler | ||
formatter = logging.Formatter(log_format) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just removes
escape_file_path
variable to avoid confusion with similarly-named but differently escaped file path a few lines below. No changes to the pattern.