OneDeadKey / kalamine

Keyboard Layout Maker
MIT License
106 stars 29 forks source link

fix: more error checking #141

Closed Geobert closed 7 months ago

Geobert commented 7 months ago

Catch errors on generating DLLs instead of panicking. Restore write permission on C files on error to avoid permission denied error on next run Revert back to \n line separator because I don’t know why, but on my system, \r\n ends into \r only in the file and rejected by kbdutools

Geobert commented 7 months ago

I ran black but didn’t get that error T_T

wismill commented 7 months ago

From the Python doc:

  • When reading input from the stream, if newline is None, universal newlines mode is enabled. Lines in the input can end in '\n', '\r', or '\r\n', and these are translated into '\n' before being returned to the caller. If it is '', universal newlines mode is enabled, but line endings are returned to the caller untranslated. If it has any of the other legal values, input lines are only terminated by the given string, and the line ending is returned to the caller untranslated.
  • When writing output to the stream, if newline is None, any '\n' characters written are translated to the system default line separator, os.linesep. If newline is '' or '\n', no translation takes place. If newline is any of the other legal values, any '\n' characters written are translated to the given string.

So you should use newline = '\r\n' but ensure you only have \n line ending in the string you pass to write. Could the issue be that pkgutil.get_data loads binary data, not string?

Geobert commented 7 months ago

Thanks! I think it’s because my data files are CRLF, must be a git setting