コード例 #1
0
def test_checking_file_duplicate():
    _, files_duplicate = wordless_checking_file.check_files_duplicate(
        main, FILES_DUPLICATE)

    assert files_duplicate == FILES_DUPLICATE
コード例 #2
0
    def add_files(self, file_paths):
        def data_received(new_files, files_detection_failed_encoding,
                          files_detection_failed_text_type,
                          files_detection_failed_lang):
            len_files_old = len(
                self.main.settings_custom['files']['files_open'])

            for new_file in new_files:
                file_names = [
                    file['name'] for file in self.main.settings_custom['files']
                    ['files_open']
                ]
                new_file['name'] = new_file[
                    'name_old'] = wordless_checking_misc.check_new_name(
                        new_file['name'], file_names)

                self.main.settings_custom['files']['files_open'].append(
                    new_file)

            wordless_msg_box.wordless_msg_box_detection_failed(
                self.main, files_detection_failed_encoding,
                files_detection_failed_text_type, files_detection_failed_lang)

            self.update_table()

            len_files_new = len(
                self.main.settings_custom['files']['files_open'])

            if len_files_new - len_files_old == 0:
                self.main.statusBar().showMessage('No files are newly opened!')
            elif len_files_new - len_files_old == 1:
                self.main.statusBar().showMessage(
                    '1 file has been successfully opened.')
            else:
                self.main.statusBar().showMessage(
                    f'{len_files_new - len_files_old} files have been successfully opened.'
                )

            dialog_progress.accept()

        file_paths, files_empty = wordless_checking_file.check_files_empty(
            self.main, file_paths)
        file_paths, files_duplicate = wordless_checking_file.check_files_duplicate(
            self.main, file_paths)
        file_paths, files_unsupported = wordless_checking_file.check_files_unsupported(
            self.main, file_paths)
        file_paths, files_parsing_error = wordless_checking_file.check_files_parsing_error(
            self.main, file_paths)

        wordless_msg_box.wordless_msg_box_file_error_on_opening(
            self.main,
            files_empty=files_empty,
            files_duplicate=files_duplicate,
            files_unsupported=files_unsupported,
            files_parsing_error=files_parsing_error)

        dialog_progress = wordless_dialog_misc.Wordless_Dialog_Progress_Add_Files(
            self.main)

        worker_add_files = Wordless_Worker_Add_Files(self.main, file_paths,
                                                     dialog_progress,
                                                     data_received)
        thread_add_files = wordless_threading.Wordless_Thread_Add_Files(
            worker_add_files)

        thread_add_files.start()

        dialog_progress.exec_()

        thread_add_files.quit()
        thread_add_files.wait()
コード例 #3
0
def test_checking_file_duplicate():
    _, files_duplicate = wordless_checking_file.check_files_duplicate(
        main, TEST_CHECKING_FILE_DUPLICATE)

    assert files_duplicate == TEST_CHECKING_FILE_DUPLICATE
コード例 #4
0
	{
	    'path': get_path('duplicate.txt')
	}
]

# Disable encoding detection
main.settings_custom['files']['auto_detection_settings']['detect_encodings'] = False

file_paths = [
    get_path('missing.txt'),
    get_path('empty.txt'),
    get_path('duplicate.txt'),
    get_path('unsupported.unsupported'),
    get_path('parsing_error.html'),
    get_path('loading_error.txt')
]

file_paths, files_missing = wordless_checking_file.check_files_missing(main, file_paths)
file_paths, files_empty = wordless_checking_file.check_files_empty(main, file_paths)
file_paths, files_duplicate = wordless_checking_file.check_files_duplicate(main, file_paths)
file_paths, files_unsupported = wordless_checking_file.check_files_unsupported(main, file_paths)
file_paths, files_parsing_error = wordless_checking_file.check_files_parsing_error(main, file_paths)
file_paths, files_loading_error = wordless_checking_file.check_files_loading_error(main, file_paths, ['utf_8'] * len(file_paths))

print(f'Missing file(s): {files_missing}')
print(f'Empty file(s): {files_empty}')
print(f'Duplicate file(s): {files_duplicate}')
print(f'Unsupported file(s): {files_unsupported}')
print(f'File(s) with parsing error(s): {files_parsing_error}')
print(f'File(s) with encoding error(s): {files_loading_error}')
コード例 #5
0
    def open_files(self, file_paths):
        def update_gui(new_files, files_detection_error_encoding,
                       files_detection_error_text_type,
                       files_detection_error_lang):
            len_files_old = len(
                self.main.settings_custom['files']['files_open'])

            for new_file in new_files:
                file_names = [
                    file['name'] for file in self.main.settings_custom['files']
                    ['files_open']
                ]
                new_file['name'] = new_file[
                    'name_old'] = wordless_checking_misc.check_new_name(
                        new_file['name'], file_names)

                self.main.settings_custom['files']['files_open'].append(
                    new_file)

            wordless_dialog_error.wordless_dialog_error_detection(
                self.main, files_detection_error_encoding,
                files_detection_error_text_type, files_detection_error_lang)

            self.update_table()

            len_files_new = len(
                self.main.settings_custom['files']['files_open'])

            if len_files_new - len_files_old == 0:
                self.main.statusBar().showMessage('No files are newly opened!')
            elif len_files_new - len_files_old == 1:
                self.main.statusBar().showMessage(
                    '1 file has been successfully opened.')
            else:
                self.main.statusBar().showMessage(
                    f'{len_files_new - len_files_old} files have been successfully opened.'
                )

        file_paths, files_empty = wordless_checking_file.check_files_empty(
            self.main, file_paths)
        file_paths, files_duplicate = wordless_checking_file.check_files_duplicate(
            self.main, file_paths)
        file_paths, files_unsupported = wordless_checking_file.check_files_unsupported(
            self.main, file_paths)
        file_paths, files_parsing_error = wordless_checking_file.check_files_parsing_error(
            self.main, file_paths)

        dialog_progress = wordless_dialog_misc.Wordless_Dialog_Progress_Open_Files(
            self.main)

        worker_open_files = Wordless_Worker_Open_Files(
            self.main,
            dialog_progress=dialog_progress,
            update_gui=update_gui,
            file_paths=file_paths)

        thread_open_files = wordless_threading.Wordless_Thread(
            worker_open_files)
        thread_open_files.start_worker()

        wordless_dialog_error.wordless_dialog_error_file_open(
            self.main,
            files_empty=files_empty,
            files_duplicate=files_duplicate,
            files_unsupported=files_unsupported,
            files_parsing_error=files_parsing_error)