Esempio n. 1
0
    def load_settings(self, defaults=False):
        if defaults:
            settings = copy.deepcopy(self.main.settings_default)
        else:
            settings = copy.deepcopy(self.main.settings_custom)

        self.line_edit_export_tables_default_path.setText(
            settings['export']['tables']['default_path'])
        self.combo_box_export_tables_default_type.setCurrentText(
            settings['export']['tables']['default_type'])
        self.combo_box_export_tables_default_encoding.setCurrentText(
            wl_conversion.to_encoding_text(
                self.main, settings['export']['tables']['default_encoding']))

        self.line_edit_export_search_terms_default_path.setText(
            settings['export']['search_terms']['default_path'])
        self.combo_box_export_search_terms_default_encoding.setCurrentText(
            wl_conversion.to_encoding_text(
                self.main,
                settings['export']['search_terms']['default_encoding']))

        self.line_edit_export_stop_words_default_path.setText(
            settings['export']['stop_words']['default_path'])
        self.combo_box_export_stop_words_default_encoding.setCurrentText(
            wl_conversion.to_encoding_text(
                self.main,
                settings['export']['stop_words']['default_encoding']))
Esempio n. 2
0
    def load_settings(self, defaults=False):
        if defaults:
            settings = copy.deepcopy(self.settings_default)
        else:
            settings = copy.deepcopy(self.settings_custom)

        # Default Settings
        self.combo_box_files_encoding.setCurrentText(
            wl_conversion.to_encoding_text(
                self.main, settings['default_settings']['encoding']))
        self.combo_box_files_lang.setCurrentText(
            wl_conversion.to_lang_text(self.main,
                                       settings['default_settings']['lang']))

        if settings['default_settings']['tokenized']:
            self.combo_box_files_tokenized.setCurrentText(self.tr('Yes'))
        else:
            self.combo_box_files_tokenized.setCurrentText(self.tr('No'))
        if settings['default_settings']['tagged']:
            self.combo_box_files_tagged.setCurrentText(self.tr('Yes'))
        else:
            self.combo_box_files_tagged.setCurrentText(self.tr('No'))

        # Auto-detection Settings
        self.spin_box_files_number_lines.setValue(
            settings['auto_detection_settings']['number_lines'])
        self.checkbox_files_number_lines_no_limit.setChecked(
            settings['auto_detection_settings']['number_lines_no_limit'])

        # Miscellaneous
        self.spin_box_read_files_in_chunks.setValue(
            settings['misc']['read_files_in_chunks'])
Esempio n. 3
0
def test_to_encoding_text():
    for encoding_code in settings_file_encodings.values():
        encoding_text = wl_conversion.to_encoding_text(main, encoding_code)

        assert encoding_text == {
            encoding_code: encoding_text
            for encoding_text, encoding_code in settings_file_encodings.items()
        }[encoding_code]
Esempio n. 4
0
def test_to_encoding_text(encoding_code):
    len_encoding_code = max([
        len(encoding_code)
        for encoding_code in main.settings_global['file_encodings'].values()
    ])
    encoding_text = wl_conversion.to_encoding_text(main, encoding_code)

    assert encoding_text == {
        encoding_code: encoding_text
        for encoding_text, encoding_code in
        main.settings_global['file_encodings'].items()
    }[encoding_code]
Esempio n. 5
0
    def update_table(self):
        self.table.blockSignals(True)
        self.table.setUpdatesEnabled(False)

        files = self.main.settings_custom['files']['files_open']

        if files:
            self.table.clear_table(len(files))

            for i, file in enumerate(files):
                checkbox_name = QTableWidgetItem(file['name'])
                combo_box_lang = wl_box.Wl_Combo_Box_Lang(self.table)
                combo_box_tokenized = wl_box.Wl_Combo_Box_Yes_No(self.table)
                combo_box_tagged = wl_box.Wl_Combo_Box_Yes_No(self.table)
                combo_box_encoding = wl_box.Wl_Combo_Box_Encoding(self.table)

                if file['selected']:
                    checkbox_name.setCheckState(Qt.Checked)
                else:
                    checkbox_name.setCheckState(Qt.Unchecked)

                combo_box_lang.setCurrentText(
                    wl_conversion.to_lang_text(self.main, file['lang']))
                combo_box_tokenized.setCurrentText(file['tokenized'])
                combo_box_tagged.setCurrentText(file['tagged'])
                combo_box_encoding.setCurrentText(
                    wl_conversion.to_encoding_text(self.main,
                                                   file['encoding']))

                combo_box_lang.currentTextChanged.connect(
                    lambda: self.table.itemChanged.emit(self.table.item(i, 1)))
                combo_box_tokenized.currentTextChanged.connect(
                    lambda: self.table.itemChanged.emit(self.table.item(i, 2)))
                combo_box_tagged.currentTextChanged.connect(
                    lambda: self.table.itemChanged.emit(self.table.item(i, 3)))
                combo_box_encoding.currentTextChanged.connect(
                    lambda: self.table.itemChanged.emit(self.table.item(i, 5)))

                self.table.setItem(i, 0, checkbox_name)
                self.table.setCellWidget(i, 1, combo_box_lang)
                self.table.setCellWidget(i, 2, combo_box_tokenized)
                self.table.setCellWidget(i, 3, combo_box_tagged)
                self.table.setItem(i, 4, QTableWidgetItem(file['path']))
                self.table.setCellWidget(i, 5, combo_box_encoding)
        else:
            self.table.clear_table(1)

        self.table.blockSignals(False)
        self.table.setUpdatesEnabled(True)

        self.table.itemChanged.emit(self.table.item(0, 0))
Esempio n. 6
0
    def load_settings(self, defaults = False):
        if defaults:
            settings = copy.deepcopy(self.settings_default)
        else:
            settings = copy.deepcopy(self.settings_custom)

        # Files
        self.line_edit_imp_files_default_path.setText(self.check_path(settings = 'files'))

        # Search Terms
        self.line_edit_imp_search_terms_default_path.setText(self.check_path(settings = 'search_terms'))
        self.combo_box_imp_search_terms_default_encoding.setCurrentText(wl_conversion.to_encoding_text(self.main, settings['search_terms']['default_encoding']))
        self.checkbox_imp_search_terms_detect_encodings.setChecked(settings['search_terms']['detect_encodings'])

        # Stop Words
        self.line_edit_imp_stop_words_default_path.setText(self.check_path(settings = 'stop_words'))
        self.combo_box_imp_stop_words_default_encoding.setCurrentText(wl_conversion.to_encoding_text(self.main, settings['stop_words']['default_encoding']))
        self.checkbox_imp_stop_words_detect_encodings.setChecked(settings['stop_words']['detect_encodings'])

        # Temporary Files
        self.line_edit_imp_temp_files_default_path.setText(self.check_path(settings = 'temp_files'))

        self.detect_encodings_changed()
Esempio n. 7
0
    def load_settings(self, defaults=False):
        if defaults:
            settings = copy.deepcopy(self.main.settings_default)
        else:
            settings = copy.deepcopy(self.main.settings_custom)

        self.spin_box_auto_detection_number_lines.setValue(
            settings['auto_detection']['detection_settings']['number_lines'])
        self.checkbox_auto_detection_number_lines_no_limit.setChecked(
            settings['auto_detection']['detection_settings']
            ['number_lines_no_limit'])

        self.combo_box_auto_detection_default_lang.setCurrentText(
            wl_conversion.to_lang_text(
                self.main, settings['auto_detection']['default_settings']
                ['default_lang']))
        self.combo_box_auto_detection_default_encoding.setCurrentText(
            wl_conversion.to_encoding_text(
                self.main, settings['auto_detection']['default_settings']
                ['default_encoding']))
Esempio n. 8
0
    def load_settings(self, defaults=False):
        if defaults:
            settings = copy.deepcopy(self.main.settings_default)
        else:
            settings = copy.deepcopy(self.main.settings_custom)

        if os.path.exists(settings['import']['files']['default_path']):
            self.line_edit_import_files_default_path.setText(
                settings['import']['files']['default_path'])
        else:
            self.line_edit_import_files_default_path.setText(
                self.main.settings_default['import']['files']['default_path'])

        if os.path.exists(settings['import']['search_terms']['default_path']):
            self.line_edit_import_search_terms_default_path.setText(
                settings['import']['search_terms']['default_path'])
        else:
            self.line_edit_import_search_terms_default_path.setText(
                self.main.settings_default['import']['search_terms']
                ['default_path'])

        self.checkbox_import_search_terms_detect_encodings.setChecked(
            settings['import']['search_terms']['detect_encodings'])

        if os.path.exists(settings['import']['stop_words']['default_path']):
            self.line_edit_import_stop_words_default_path.setText(
                settings['import']['stop_words']['default_path'])
        else:
            self.line_edit_import_stop_words_default_path.setText(
                self.main.settings_default['import']['stop_words']
                ['default_path'])

        self.checkbox_import_stop_words_detect_encodings.setChecked(
            settings['import']['stop_words']['detect_encodings'])

        self.line_edit_import_temp_files_default_path.setText(
            settings['import']['temp_files']['default_path'])
        self.combo_box_import_temp_files_default_encoding.setCurrentText(
            wl_conversion.to_encoding_text(
                self.main,
                settings['import']['temp_files']['default_encoding']))