Beispiel #1
0
    def _insert_bookmarks(self, bookmarks, silent=False):
        """Method for inserting bookmark data already loaded.

        :param bookmarks: bookmarks to import in the UI
        :type bookmarks: dict
        """

        count = 0
        for line in bookmarks:

            logger.info(line)
            error = False
            if len(line) < LEN_BM:
                line.append("O")
            if frequency_pp_parse(line[BM.freq]) == None:
                error = True
            try:
                line[BM.freq] = frequency_pp(line[BM.freq])
            except ValueError:
                logger.exception("Malformed bookmark in {}"\
                                 " skipping...".format(line))
                continue
            if line[BM.mode] not in CBB_MODES:
                error = True
            if error == True:
                if not silent:
                    tkMessageBox.showerror("Error", "Invalid value in "\
                                           "Bookmark #%i. "\
                                           "Skipping..." %count)
            else:
                item = self.tree.insert('', tk.END, values=line)
                self.bookmark_bg_tag(item, line[BM.lockout])