267 Public method to save the modified file. |
269 Public method to save the modified file. |
268 |
270 |
269 @param encoding encoding of the source file (string) |
271 @param encoding encoding of the source file (string) |
270 @return error message on failure (tuple of str) |
272 @return error message on failure (tuple of str) |
271 """ |
273 """ |
272 import codecs |
|
273 |
|
274 if not self.__modified: |
274 if not self.__modified: |
275 # no need to write |
275 # no need to write |
276 return None |
276 return None |
277 |
277 |
278 if self.__createBackup: |
278 if self.__createBackup: |
2740 and not newText[-1].isalnum() |
2740 and not newText[-1].isalnum() |
2741 ): |
2741 ): |
2742 # Trim comments that end with things like --------- |
2742 # Trim comments that end with things like --------- |
2743 return newText[:maxLength] + self.__eol |
2743 return newText[:maxLength] + self.__eol |
2744 elif isLast and re.match(r"\s*#+\s*\w+", newText): |
2744 elif isLast and re.match(r"\s*#+\s*\w+", newText): |
2745 import textwrap |
|
2746 |
|
2747 splitLines = textwrap.wrap( |
2745 splitLines = textwrap.wrap( |
2748 newText.lstrip(" \t#"), |
2746 newText.lstrip(" \t#"), |
2749 initial_indent=indentation, |
2747 initial_indent=indentation, |
2750 subsequent_indent=indentation, |
2748 subsequent_indent=indentation, |
2751 width=maxLength, |
2749 width=maxLength, |