You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering whether the filename could be normalized, at least under windows, before creating the file with the filename of the title.
For the moment I'm importing unicodedata and using the following verbose code (and not immune to errors, as I allow the \ to be in the filename, as it is used for referring to the partial path) in export_txt to make things work:
try:
with open(filename, 'wb') as f:
f.write("\n\n---\n\n".join(lines))
except:
oldfilename = filename
filename = unicodedata.normalize('NFKD', filename).encode('ascii','ignore')
valid_chars = '\\-_.() abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
filename = ''.join(c for c in filename if c in valid_chars)
print 'Converting', oldfilename, 'to', filename
with open(filename, 'wb') as f:
f.write("\n\n---\n\n".join(lines))
Thanks
The text was updated successfully, but these errors were encountered:
I have the same problem described here
http://stackoverflow.com/questions/22620965/ioerror-errno-22-invalid-mode-wb-or-filename
I was wondering whether the filename could be normalized, at least under windows, before creating the file with the filename of the title.
For the moment I'm importing unicodedata and using the following verbose code (and not immune to errors, as I allow the \ to be in the filename, as it is used for referring to the partial path) in export_txt to make things work:
Thanks
The text was updated successfully, but these errors were encountered: