def apply_settings(self): settings = self.main.settings_custom settings['export']['tables'][ 'default_path'] = self.line_edit_export_tables_default_path.text() settings['export']['tables'][ 'default_type'] = self.combo_box_export_tables_default_type.currentText( ) settings['export']['tables'][ 'default_encoding'] = wl_conversion.to_encoding_code( self.main, self.combo_box_export_tables_default_encoding.currentText()) settings['export']['search_terms'][ 'default_path'] = self.line_edit_export_search_terms_default_path.text( ) settings['export']['search_terms'][ 'default_encoding'] = wl_conversion.to_encoding_code( self.main, self.combo_box_export_search_terms_default_encoding. currentText()) settings['export']['stop_words'][ 'default_path'] = self.line_edit_export_stop_words_default_path.text( ) settings['export']['stop_words'][ 'default_encoding'] = wl_conversion.to_encoding_code( self.main, self.combo_box_export_stop_words_default_encoding.currentText( )) return True
def apply_settings(self): settings = self.main.settings_custom settings['import']['files'][ 'default_path'] = self.line_edit_import_files_default_path.text() settings['import']['search_terms'][ 'default_path'] = self.line_edit_import_search_terms_default_path.text( ) settings['import']['search_terms'][ 'detect_encodings'] = self.checkbox_import_search_terms_detect_encodings.isChecked( ) settings['import']['stop_words'][ 'default_path'] = self.line_edit_import_stop_words_default_path.text( ) settings['import']['stop_words'][ 'detect_encodings'] = self.checkbox_import_stop_words_detect_encodings.isChecked( ) settings['import']['temp_files'][ 'default_path'] = self.line_edit_import_temp_files_default_path.text( ) settings['import']['temp_files'][ 'default_encoding'] = wl_conversion.to_encoding_code( self.main, self.combo_box_import_temp_files_default_encoding.currentText( )) return True
def apply_settings(self): # Default Settings self.settings_custom['default_settings'][ 'encoding'] = wl_conversion.to_encoding_code( self.main, self.combo_box_files_encoding.currentText()) self.settings_custom['default_settings'][ 'lang'] = wl_conversion.to_lang_code( self.main, self.combo_box_files_lang.currentText()) if self.combo_box_files_tokenized.currentText() == self.tr('Yes'): self.settings_custom['default_settings']['tokenized'] = True else: self.settings_custom['default_settings']['tokenized'] = False if self.combo_box_files_tagged.currentText() == self.tr('Yes'): self.settings_custom['default_settings']['tagged'] = True else: self.settings_custom['default_settings']['tagged'] = True # Auto-detection Settings self.settings_custom['auto_detection_settings'][ 'number_lines'] = self.spin_box_files_number_lines.value() self.settings_custom['auto_detection_settings'][ 'number_lines_no_limit'] = self.checkbox_files_number_lines_no_limit.isChecked( ) # Miscellaneous self.settings_custom['misc'][ 'read_files_in_chunks'] = self.spin_box_read_files_in_chunks.value( ) return True
def test_to_encoding_code(encoding_text): len_encoding_text = max([ len(encoding_text) for encoding_text in main.settings_global['file_encodings'] ]) encoding_code = wl_conversion.to_encoding_code(main, encoding_text) assert encoding_code == main.settings_global['file_encodings'][ encoding_text]
def apply_settings(self): # Files self.settings_custom['files']['default_path'] = self.line_edit_imp_files_default_path.text() # Search Terms self.settings_custom['search_terms']['default_path'] = self.line_edit_imp_search_terms_default_path.text() self.settings_custom['search_terms']['default_encoding'] = wl_conversion.to_encoding_code(self.main, self.combo_box_imp_search_terms_default_encoding.currentText()) self.settings_custom['search_terms']['detect_encodings'] = self.checkbox_imp_search_terms_detect_encodings.isChecked() # Stop Words self.settings_custom['stop_words']['default_path'] = self.line_edit_imp_stop_words_default_path.text() self.settings_custom['stop_words']['default_encoding'] = wl_conversion.to_encoding_code(self.main, self.combo_box_imp_stop_words_default_encoding.currentText()) self.settings_custom['stop_words']['detect_encodings'] = self.checkbox_imp_stop_words_detect_encodings.isChecked() # Temporary Files self.settings_custom['temp_files']['default_path'] = self.line_edit_imp_temp_files_default_path.text() return True
def apply_settings(self): settings = self.main.settings_custom settings['auto_detection']['detection_settings'][ 'number_lines'] = self.spin_box_auto_detection_number_lines.value( ) settings['auto_detection']['detection_settings'][ 'number_lines_no_limit'] = self.checkbox_auto_detection_number_lines_no_limit.isChecked( ) settings['auto_detection']['default_settings'][ 'default_lang'] = wl_conversion.to_lang_code( self.main, self.combo_box_auto_detection_default_lang.currentText()) settings['auto_detection']['default_settings'][ 'default_encoding'] = wl_conversion.to_encoding_code( self.main, self.combo_box_auto_detection_default_encoding.currentText()) return True
def file_item_changed(self): if any([self.item(0, i) for i in range(self.columnCount())]): # Check for duplicate file names for row in range(self.rowCount()): file_name = self.item(row, 0).text() file_path = self.item(row, 4).text() file = self.main.wl_files.find_file_by_path(file_path) if file_name != file['name_old']: if self.main.wl_files.find_file_by_name(file_name): self.blockSignals(True) self.item(row, 0).setText(file['name_old']) self.blockSignals(False) wl_msg_box.wl_msg_box_duplicate_file_name(self.main) self.closePersistentEditor(self.item(row, 0)) self.editItem(self.item(row, 0)) break self.main.settings_custom['files']['files_open'].clear() for row in range(self.rowCount()): new_file = {} lang_text = self.cellWidget(row, 1).currentText() encoding_text = self.cellWidget(row, 5).currentText() new_file['selected'] = True if self.item( row, 0).checkState() == Qt.Checked else False new_file['name'] = new_file['name_old'] = self.item(row, 0).text() new_file['lang'] = wl_conversion.to_lang_code( self.main, lang_text) new_file['tokenized'] = self.cellWidget(row, 2).currentText() new_file['tagged'] = self.cellWidget(row, 3).currentText() new_file['path'] = self.item(row, 4).text() new_file['encoding'] = wl_conversion.to_encoding_code( self.main, encoding_text) self.main.settings_custom['files']['files_open'].append( new_file) self.button_close_all.setEnabled(True) else: self.button_close_all.setEnabled(False) if self.main.settings_custom['files']['files_closed']: self.button_reopen.setEnabled(True) else: self.button_reopen.setEnabled(False) # Menu if any([self.item(0, i) for i in range(self.columnCount())]): self.main.find_menu_item(self.tr('Select All')).setEnabled(True) self.main.find_menu_item( self.tr('Invert Selection')).setEnabled(True) self.main.find_menu_item(self.tr('Deselect All')).setEnabled(True) self.main.find_menu_item(self.tr('Close All')).setEnabled(True) else: self.main.find_menu_item(self.tr('Select All')).setEnabled(False) self.main.find_menu_item( self.tr('Invert Selection')).setEnabled(False) self.main.find_menu_item(self.tr('Deselect All')).setEnabled(False) self.main.find_menu_item(self.tr('Close All')).setEnabled(False) if self.main.settings_custom['files']['files_closed']: self.main.find_menu_item( self.tr('Reopen Closed Files')).setEnabled(True) else: self.main.find_menu_item( self.tr('Reopen Closed Files')).setEnabled(False) if self.rowCount() == 0: self.setRowCount(1) self.file_selection_changed()
def test_to_encoding_code(): for encoding_text in settings_file_encodings.keys(): encoding_code = wl_conversion.to_encoding_code(main, encoding_text) assert encoding_code == settings_file_encodings[encoding_text]