<commit_before># -*- coding: utf-8 -*-
from PyQt4 import QtGui, QtCore
from ui.ui_settings import Ui_SettingsDialog


class SettingsDialog(QtGui.QDialog, Ui_SettingsDialog):
    def __init__(self, iface, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.iface = iface
        self.parent = parent
        self.setupUi(self)

        self.restoreState()

    def restoreState(self):
        """
        Reinstate the options based on the user's stored session info.
        """
        mySettings = QtCore.QSettings()
        self.usernameEdit.setText(
            mySettings.value('svir/platform_username', ''))
        self.passwordEdit.setText(
            mySettings.value('svir/platform_password', ''))
        self.hostnameEdit.setText(
            mySettings.value('svir/platform_hostname',
                             'https://platform.openquake.org'))
        self.developermodeCheck.setChecked(
            mySettings.value('svir/developer_mode', False, type=bool))

    def saveState(self):
        """
        Store the options into the user's stored session info.
        """
        mySettings = QtCore.QSettings()
        mySettings.setValue('svir/platform_hostname',
                            self.hostnameEdit.text())
        mySettings.setValue('svir/platform_username',
                            self.usernameEdit.text())
        mySettings.setValue('svir/platform_password',
                            self.passwordEdit.text())
        mySettings.setValue('svir/developer_mode',
                            self.developermodeCheck.isChecked())

    def accept(self):
        """
        Method invoked when OK button is clicked.
        """
        self.saveState()
        self.close()<commit_msg>fix wrong mac settings behaviour<commit_after># -*- coding: utf-8 -*-
from PyQt4 import QtGui, QtCore
from ui.ui_settings import Ui_SettingsDialog


class SettingsDialog(QtGui.QDialog, Ui_SettingsDialog):
    def __init__(self, iface, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.iface = iface
        self.parent = parent
        self.setupUi(self)

        self.restoreState()

    def restoreState(self):
        """
        Reinstate the options based on the user's stored session info.
        """
        mySettings = QtCore.QSettings()
        platform_username = mySettings.value('svir/platform_username', '')
        platform_password = mySettings.value('svir/platform_password', '')
        platform_hostname = mySettings.value(
            'svir/platform_hostname', 'https://platform.openquake.org')

        # hack for strange mac behaviour
        platform_username = (
            platform_username if platform_username is not None else '')
        platform_password = (
            platform_password if platform_password is not None else '')
        platform_hostname = (
            platform_hostname if platform_hostname is not None else '')
        self.passwordEdit.setText(platform_password)
        self.usernameEdit.setText(platform_username)
        self.hostnameEdit.setText(platform_hostname)
        
        self.developermodeCheck.setChecked(
            mySettings.value('svir/developer_mode', False, type=bool))

    def saveState(self):
        """
        Store the options into the user's stored session info.
        """
        mySettings = QtCore.QSettings()
        mySettings.setValue('svir/platform_hostname',
                            self.hostnameEdit.text())
        mySettings.setValue('svir/platform_username',
                            self.usernameEdit.text())
        mySettings.setValue('svir/platform_password',
                            self.passwordEdit.text())
        mySettings.setValue('svir/developer_mode',
                            self.developermodeCheck.isChecked())

    def accept(self):
        """
        Method invoked when OK button is clicked.
        """
        self.saveState()
        self.close()
{'fraction_non_alphanumeric': 0.09951886553557862, 'fraction_numerical': 0.0010129146619397315, 'mean_word_length': 2.17524115755627, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3272633', 'n_tokens_mistral': 1019, 'n_tokens_neox': 1023, 'n_words': 204}