digitaldomain / QtPyConvert

An automatic Python Qt binding transpiler to the Qt.py abstraction layer.
Other
69 stars 3 forks source link

Conversion appends a new line which is always unix style #10

Open blaisejarrett opened 6 years ago

blaisejarrett commented 6 years ago

When converting a file the tool seems to append a new line to the end of the file under certain conditions - Not sure what conditions.

When it appends a new line it seems to always append a "\n" unix style new line. Even when the rest of the file may have different line endings.

  1. Does the tool have to append a newline? If so.
  2. Can the output file have consistent line endings that ideally match the sources line endings?

Before source:

from PySide import QtGui
if __name__ == '__main__':
    QtGui.QApplication([])

Before source as Hex:

00000010: 7274 2051 7447 7569 0d0a 6966 205f 5f6e  rt QtGui..if __n
00000020: 616d 655f 5f20 3d3d 2027 5f5f 6d61 696e  ame__ == '__main
00000030: 5f5f 273a 0d0a 2020 2020 5174 4775 692e  __':..    QtGui.
00000040: 5141 7070 6c69 6361 7469 6f6e 285b 5d29  QApplication([])

Source after:

from Qt import QtWidgets
if __name__ == '__main__':
    QtWidgets.QApplication([])

Source after as Hex:

00000010: 7457 6964 6765 7473 0d0a 6966 205f 5f6e  tWidgets..if __n
00000020: 616d 655f 5f20 3d3d 2027 5f5f 6d61 696e  ame__ == '__main
00000030: 5f5f 273a 0d0a 2020 2020 5174 5769 6467  __':..    QtWidg
00000040: 6574 732e 5141 7070 6c69 6361 7469 6f6e  ets.QApplication
00000050: 285b 5d29 0a                             ([]).

Note the 0a \n newline at the end of the file even though the file previously contained 0d0a \r\n windows style newlines.

Ahuge commented 6 years ago

Looks like the underlying redbaron ast is adding this.

I will see if I can disable this. If not, I will filter line endings before I output the result and make sure they all conform.