Пример #1
0
 def test_that_the_outputs_attribute_of_a_node_is_a_mapping(self):
     n = Node()
     exception = None
     try:
         n.outputs.values()
     except AttributeError as e:
         exception = e
     ok_(exception is None,
         "\n  Test accessing `outputs.values()`" +
         " on {} having no inputs.".format(n) +
         "\n  Got unexpected exception:\n" +
         "\n      {}".format(feo(type(exception), exception)[0]))
Пример #2
0
 def test_that_the_outputs_attribute_of_a_node_is_a_mapping(self):
     n = Node()
     exception = None
     try:
         values = n.outputs.values()
     except AttributeError as e:
         exception = e
     ok_(exception is None,
         "\n  Test accessing `outputs.values()`" +
         " on {} having no inputs.".format(n) +
         "\n  Got unexpected exception:\n" +
         "\n      {}".format(feo(type(exception), exception)[0]))
Пример #3
0
 def test_accessing_inputs_of_a_node_without_input_flows(self):
     n = Node()
     exception = None
     try:
         inputs = n.inputs
     except Exception as e:
         exception = e
     ok_(exception is None,
         "\n  Test accessing `inputs` on {} having no inputs.".format(n) +
         "\n  Got unexpected exception:\n" +
         "\n      {}".format(feo(type(exception), exception)[0]))
     ok_(len(inputs) == 0,
         "\n  Failure when testing `len(inputs)`." +
         "\n  Expected: 0." +
         "\n  Got     : {}".format(len(inputs)))
Пример #4
0
 def test_accessing_inputs_of_a_node_without_input_flows(self):
     n = Node()
     exception = None
     try:
         inputs = n.inputs
     except Exception as e:
         exception = e
     ok_(exception is None,
         "\n  Test accessing `inputs` on {} having no inputs.".format(n) +
         "\n  Got unexpected exception:\n" +
         "\n      {}".format(feo(type(exception), exception)[0]))
     ok_(len(inputs) == 0,
         "\n  Failure when testing `len(inputs)`." +
         "\n  Expected: 0." +
         "\n  Got     : {}".format(len(inputs)))
Пример #5
0
    def open_chooser(self, action):
        if not os.path.exists(self.last_dir):
            self.last_dir = const.HOME

        if action.get_name() == "AddFolders":
            chooser = FolderChooser(self, _("Add Music"), self.last_dir)
            cb = gtk.CheckButton(_("Watch this folder for new songs"))
            cb.set_active(not config.get("settings", "scan"))
            cb.show()
            chooser.set_extra_widget(cb)
        else:
            chooser = FileChooser(
                self, _("Add Music"), formats.filter, self.last_dir)
            cb = None

        fns = chooser.run()
        chooser.destroy()
        if fns:
            if action.get_name() == "AddFolders":
                self.last_dir = fns[0]
                copool.add(self.__library.scan, fns, funcid="library")
            else:
                self.last_dir = os.path.basename(fns[0])
                for filename in map(os.path.realpath, map(util.fsnative, fns)):
                    if filename in self.__library: continue
                    song = self.__library.add_filename(filename)
                    if not song:
                        from traceback import format_exception_only as feo
                        tb = feo(sys.last_type, sys.last_value)
                        msg = _("%s could not be added to your library.\n\n")
                        msg %= util.escape(util.fsdecode(
                            os.path.basename(filename)))
                        msg += util.escape("".join(tb).decode(
                            const.ENCODING, "replace"))
                        d = ErrorMessage(self, _("Unable to add song"), msg)
                        d.label.set_selectable(True)
                        d.run()
                        continue

        if cb and cb.get_active():
            dirs = util.split_scan_dirs(config.get("settings", "scan"))
            for fn in fns:
                if fn not in dirs: dirs.append(fn)
            dirs = ":".join(dirs)
            config.set("settings", "scan", dirs)