View Single Post
Old 10-17-2020, 12:54 AM   #1
cuser
Member
cuser began at the beginning.
 
Posts: 18
Karma: 10
Join Date: Oct 2020
Device: kindle
calibre-utf8-path

https://github.com/snomiao/calibre-utf8-path

backend.py
filenames.py

Code:
def replace_invalid_filename_char(filename, replaced_char=''):
    '''Replace the invalid characaters in the filename with specified characater.
    The default replaced characater is '_'.
    e.g.
    C/C++ -> C_C++
    '''
    valid_filename = filename
    invalid_characaters = '\/:*?"<>|'
    for c in invalid_characaters:
        valid_filename = valid_filename.replace('【', '[')
        valid_filename = valid_filename.replace('】', ']')
        valid_filename = valid_filename.replace(c, replaced_char)
    return valid_filename
Code:
    def delete_originals(self):
        import win32file
        for path in self.handle_map:
            #win32file.DeleteFileW(path)
            os.remove(path)
        self.close_handles()
cuser is offline   Reply With Quote