simulatino / trimtrailingwhitespaces

Python script that detects textfiles and then removes trailing white spaces and more.
The Unlicense
11 stars 2 forks source link

ttws fails on zero-byte files #19

Open tbeu opened 10 years ago

tbeu commented 10 years ago

Empty files (e.g. package.order) raise an exception instead of simply being ignored.

trimming c:/Projects/Thermocycle-library_tbeu/ThermoCycle\Media\D4_CP\package.order

Oops! Failing to process file: c:/Projects/Thermocycle-library_tbeu/ThermoCycle\Media\D4_CP\package.order
Are you sure it is of pure ASCII or UTF8 encoding?
Traceback (most recent call last):
  File "c:\Python27\Scripts\ttws-script.py", line 9, in <module>
    load_entry_point('ttws==0.5.1-dev', 'console_scripts', 'ttws')()
  File "C:\Python27\lib\site-packages\ttws-0.5.1_dev-py2.7.egg\ttws\cli.py", line 77, in main
    trimWhitespace(filepath, eol)
  File "C:\Python27\lib\site-packages\ttws-0.5.1_dev-py2.7.egg\ttws\__init__.py", line 87, in trimWhitespace
    target.write("\n".join(lines) + "\n")
TypeError: must be unicode, not str
dietmarw commented 10 years ago

Thanks, again only a problem that occurs on Windows w/o libmagic ;-). I'll see what workaround I can come up with.

tbeu commented 10 years ago

Why is there no libmagic on Windows?

dietmarw commented 10 years ago

Look at: https://github.com/ahupp/python-magic#dependencies

dietmarw commented 10 years ago

I would be glad if you can come up with fix for that which would kind of install libmagic on windows together with ttws.

tbeu commented 10 years ago

I will see what I can do. Last time I asked Christoph Gohlke if he can provide the extension package.

dietmarw commented 4 years ago

@beutlich Any news here?

tbeu commented 4 years ago

I simply forgot about it.