def test_set_parameters(self):
        sw_path = RecentPath.create("Foo", [])
        lx_path = RecentPath.create("Bar", [])
        params = {"methods": [FilteringModule.Lexicon, FilteringModule.Regexp],
                  "language": "Finnish",
                  "sw_path": sw_path, "lx_path": lx_path,
                  "sw_list": [sw_path], "lx_list": [lx_path],
                  "pattern": "foo", "start": 0.2, "end": 0.7, "n_tokens": 10,
                  "invalidated": False}
        self.editor.setParameters(params)
        self.assertDictEqual(self.editor.parameters(), params)

        check_boxes = self.check_boxes
        self.assertFalse(check_boxes[0].isChecked())
        self.assertTrue(check_boxes[1].isChecked())
        self.assertTrue(check_boxes[2].isChecked())
        self.assertFalse(check_boxes[3].isChecked())
        self.assertFalse(check_boxes[4].isChecked())

        self.assertEqual(self.combo.currentText(), "Finnish")
        self.assertEqual(self.sw_combo.currentText(), "Foo")
        self.assertEqual(self.lx_combo.currentText(), "Bar")
        self.assertEqual(self.line_edit.text(), "foo")
        self.assertEqual(self.spins[0].value(), 0.2)
        self.assertEqual(self.spins[1].value(), 0.7)
        self.assertEqual(self.spin.value(), 10)
Exemple #2
0
    def __relocate_file(self, path: RecentPath) -> RecentPath:
        basedir = self.workflowEnv().get("basedir", None)
        if basedir is None or path is None:
            return path

        search_paths = [("basedir", basedir)]
        resolved = path.resolve(search_paths)
        kwargs = dict(title=path.title, sheet=path.sheet,
                      file_format=path.file_format)
        if resolved is not None:
            return RecentPath.create(resolved.abspath, search_paths, **kwargs)
        elif path.search(search_paths) is not None:
            return RecentPath.create(path.search(search_paths),
                                     search_paths, **kwargs)
        return path
Exemple #3
0
 def add_path(self, filename: str):
     recent = RecentPath.create(filename, [])
     if recent in self.recent_paths:
         self.recent_paths.remove(recent)
     self.recent_paths.insert(0, recent)
     self.set_file_list()
Exemple #4
0
 def str_into_paths(label):
     files = [
         RecentPath.create(path, [])
         for path in filters[label] if path != _DEFAULT_NONE
     ]
     return files[0] if files else None, files