Exemple #1
0
class MatchingOptionsPage(OptionsPage):

    NAME = "matching"
    TITLE = N_("Matching")
    PARENT = "advanced"
    SORT_ORDER = 30
    ACTIVE = True
    HELP_URL = '/config/options_matching.html'

    options = [
        FloatOption("setting", "file_lookup_threshold", 0.7),
        FloatOption("setting", "cluster_lookup_threshold", 0.7),
        FloatOption("setting", "track_matching_threshold", 0.4),
    ]

    _release_type_sliders = {}

    def __init__(self, parent=None):
        super().__init__(parent)
        self.ui = Ui_MatchingOptionsPage()
        self.ui.setupUi(self)

    def load(self):
        config = get_config()
        self.ui.file_lookup_threshold.setValue(int(config.setting["file_lookup_threshold"] * 100))
        self.ui.cluster_lookup_threshold.setValue(int(config.setting["cluster_lookup_threshold"] * 100))
        self.ui.track_matching_threshold.setValue(int(config.setting["track_matching_threshold"] * 100))

    def save(self):
        config = get_config()
        config.setting["file_lookup_threshold"] = float(self.ui.file_lookup_threshold.value()) / 100.0
        config.setting["cluster_lookup_threshold"] = float(self.ui.cluster_lookup_threshold.value()) / 100.0
        config.setting["track_matching_threshold"] = float(self.ui.track_matching_threshold.value()) / 100.0
Exemple #2
0
    def test_float_opt_set_read_back(self):
        FloatOption("setting", "float_option", 666.6)

        # set option and read back
        self.config.setting["float_option"] = 333.3
        self.assertEqual(self.config.setting["float_option"], 333.3)
        self.assertIs(type(self.config.setting["float_option"]), float)
Exemple #3
0
class EchoNestOptionsPage(OptionsPage):
    NAME = "echonest"
    TITLE = "echonest"
    PARENT = "plugins"

    options = [
        BoolOption("setting", "echonest_upload", False),
        BoolOption("setting", "echonest_artist_title_lookup", True),
        FloatOption("setting", "echonest_duration_diff", 5.0),
    ]

    def __init__(self, parent=None):
        super(EchoNestOptionsPage, self).__init__(parent)
        self.ui = Ui_EchoNestOptionsPage()
        self.ui.setupUi(self)

    def load(self):
        #self.ui.echonest_upload.setChecked(self.config.setting["echonest_upload"])
        self.ui.echonest_artist_title_lookup.setChecked(self.config.setting["echonest_artist_title_lookup"])
        #self.ui.echonest_duration_diff.setChecked(self.config.setting["echonest_duration_diff"])

    def save(self):
        #self.config.setting["echonest_upload"] = self.ui.echonest_upload.isChecked()
        self.config.setting["echonest_artist_title_lookup"] = self.ui.echonest_artist_title_lookup.isChecked()
Exemple #4
0
    def test_float_opt_direct_validstr(self):
        FloatOption("setting", "float_option", 666.6)

        # store float as string directly, it should be ok, due to conversion
        self.config.setValue('setting/float_option', '333.3')
        self.assertEqual(self.config.setting["float_option"], 333.3)
Exemple #5
0
    def test_float_opt_direct_invalid(self):
        FloatOption("setting", "float_option", 666.6)

        # store invalid float value in config file directly
        self.config.setValue('setting/float_option', '333.3x')
        self.assertEqual(self.config.setting["float_option"], 666.6)
Exemple #6
0
    def test_float_opt_set_none(self):
        FloatOption("setting", "float_option", 666.6)

        # set option to None
        self.config.setting["float_option"] = None
        self.assertEqual(self.config.setting["float_option"], 666.6)
Exemple #7
0
    def test_float_opt_not_float(self):
        FloatOption("setting", "float_option", 666.6)

        # set option to invalid value
        self.config.setting["float_option"] = 'invalid'
        self.assertEqual(self.config.setting["float_option"], 666.6)
Exemple #8
0
    def test_float_opt_no_config(self):
        FloatOption("setting", "float_option", 666.6)

        # test default, nothing in config yet
        self.assertEqual(self.config.setting["float_option"], 666.6)
        self.assertIs(type(self.config.setting["float_option"]), float)
Exemple #9
0
 def test_float_opt_convert(self):
     opt = FloatOption("setting", "float_option", 666.6)
     self.assertEqual(opt.convert("333.3"), 333.3)
Exemple #10
0
 def test_float_opt_convert(self):
     opt = FloatOption("setting", "float_option", 666.6)
     self.assertEqual(opt.convert("333.3"), 333.3)