Exemplo n.º 1
0
 def setUp(self):
     quodlibet.config.init()
     h, self.fname = mkstemp()
     os.close(h)
     with open(self.fname + ".saved", "w") as f:
         f.write("%s\n%s\n" %
                 (self.TEST_KV_DATA[0][1], self.TEST_KV_DATA[0][0]))
     self.sae = StandaloneEditor(self.fname, "test", None, None)
Exemplo n.º 2
0
 def test_defaults(self):
     defaults = [("Dot-com Dream", "http://<artist>.com")]
     try:
         os.unlink(self.fname)
     except OSError:
         pass
     # Now create a new SAE without saved results and use defaults
     self.fname = "foo"
     self.sae.destroy()
     self.sae = StandaloneEditor(self.fname, "test2", defaults, None)
     self.sae.write()
     data = [(row[1], row[0]) for row in self.sae.model]
     self.failUnlessEqual(defaults, data)
Exemplo n.º 3
0
    def edit_patterns(cls, button):
        def valid_uri(s):
            # TODO: some pattern validation too (that isn't slow)
            try:
                p = Pattern(s)
                return (p and uri_is_valid(s))
            except ValueError:
                return False

        win = StandaloneEditor(filename=cls.PATTERNS_FILE,
                               title=_("Search URL patterns"),
                               initial=cls.DEFAULT_URL_PATS,
                               validator=valid_uri)
        win.show()