Jason R. Coombs <jar...@jaraco.com> added the comment:

I looked into the possibility of retaining newline characters even for files 
with mixed newlines, but I've decided that's too intrusive an approach. The 
current implementation specifically takes measures to strip whitespaces from 
the ends of lines, so it seems outside the scope of this bug to alter that 
behavior.

So I've taken another stab at a more robust implementation that does newline 
detection but raises an error if the file contains mixed newlines.

Furthermore, it adds an option (--newline) to specify which newline character 
to use, bypassing the mixed-newline error and allowing the user to override 
newline detection.

Here's a demo run:

    PS C:\cpython-issue10639> python .\Tools\scripts\reindent.py .\foo.py
    .\foo.py: mixed newlines detected; cannot continue without --newline
    PS C:\cpython-issue10639> python .\Tools\scripts\reindent.py --newline CRLF 
.\foo.py
    PS C:\cpython-issue10639> python .\Tools\scripts\reindent.py --newline LF 
.\foo.py
    PS C:\cpython-issue10639> python .\Tools\scripts\reindent.py .\foo.py

I've published this change as 
https://bitbucket.org/jaraco/cpython-issue10639/changeset/900df5732f93.

Please review. If this changeset is acceptable, I will push the revisions to 
the master repo. Please advise if I may also backport to Python 3.2 and 2.7.

----------
hgrepos: +45

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue10639>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to