Example #1
0
 def get_tag_opt(self, tag, option):
     tc = self.get_tag_conf(tag)
     valid, value = access_dict(tc, option)
     if not valid:
         return None
     return value
Example #2
0
 def get_tag_opt(self, tag, option):
     tc = self.get_tag_conf(tag)
     valid, value = access_dict(tc, option)
     if not valid:
         return None
     return value
Example #3
0
 def get_opt(self, option):
     c = self.get_conf()
     valid, value = access_dict(c, option)
     if not valid:
         return None
     return value
Example #4
0
 def get_opt(self, option):
     c = self.get_conf()
     valid, value = access_dict(c, option)
     if not valid:
         return None
     return value
Example #5
0
    def cmd_set(self, opt, val):
        log.debug("SET: %s '%s'" % (opt, val))

        evaluate = needs_eval(opt)

        if val != "" and evaluate:
            log.debug("Evaluating...")
            try:
                val = eval(val)
            except Exception as e:
                log.error("Couldn't eval '%s': %s" % (val, e))
                return

        if opt.startswith("defaults."):
            conf = {"defaults": self.callbacks["get_defaults"]()}

            if val != "":
                assign_to_dict(conf, opt, val)
                self.callbacks["set_defaults"](conf["defaults"])
        elif opt.startswith("feed."):
            sel = self.callbacks["get_var"]("selected")
            if not sel:
                log.info("Feed settings only work with a selected item")
                return

            if sel.is_tag:
                try_tag = sel
            else:
                try_tag = sel.parent_tag

            if not try_tag.tag.startswith("maintag:"):
                log.info(
                    "Selection is in a user tag, cannot set feed settings")
                return

            name = try_tag.tag[8:]

            conf = {"feed": self.callbacks["get_feed_conf"](name)}

            if val != "":
                assign_to_dict(conf, opt, val)
                self.callbacks["set_feed_conf"](name, conf["feed"])
        elif opt.startswith("tag."):
            sel = self.callbacks["get_var"]("selected")
            if not sel:
                log.info("Tag settings only work with a selected item")
                return

            if sel.is_tag:
                tag = sel
            else:
                tag = sel.parent_tag

            conf = {"tag": self.callbacks["get_tag_conf"](tag.tag)}

            if val != "":
                assign_to_dict(conf, opt, val)
                self.callbacks["set_tag_conf"](tag.tag, conf["tag"])
        else:
            conf = self.callbacks["get_conf"]()

            if val != "":
                assign_to_dict(conf, opt, val)
                self.callbacks["set_conf"](conf)

        ok, val = access_dict(conf, opt)
        if not ok:
            log.error("Unknown option %s" % opt)
            log.error("Full conf: %s" % conf)
        else:
            log.info("%s = %s" % (opt, val))
Example #6
0
 def compare_config(self, config, var, evalue):
     ok, got = access_dict(config, var)
     if not ok:
         raise Exception("Couldn't get %s?" % var)
     if got != evalue:
         raise Exception("Expected %s == %s - got %s" % (var, evalue, got))
Example #7
0
 def _get_opt(self, option, d):
     valid, value = access_dict(d, option)
     if not valid:
         return None
     return value
Example #8
0
    def cmd_set(self, opt, val):
        log.debug("SET: %s '%s'" % (opt, val))

        evaluate = needs_eval(opt)

        if val != "" and evaluate:
            log.debug("Evaluating...")
            try:
                val = eval(val)
            except Exception as e:
                log.error("Couldn't eval '%s': %s" % (val, e))
                return

        if opt.startswith("defaults."):
            conf = { "defaults" : self.callbacks["get_defaults"]() }

            if val != "":
                assign_to_dict(conf, opt, val)
                self.callbacks["set_defaults"](conf["defaults"])
        elif opt.startswith("feed."):
            sel = self.callbacks["get_var"]("selected")
            if not sel:
                log.info("Feed settings only work with a selected item")
                return

            if sel.is_tag:
                try_tag = sel
            else:
                try_tag = sel.parent_tag

            if not try_tag.tag.startswith("maintag:"):
                log.info("Selection is in a user tag, cannot set feed settings")
                return

            name = try_tag.tag[8:]

            conf = { "feed" : self.callbacks["get_feed_conf"](name) }

            if val != "":
                assign_to_dict(conf, opt, val)
                self.callbacks["set_feed_conf"](name, conf["feed"])
        elif opt.startswith("tag."):
            sel = self.callbacks["get_var"]("selected")
            if not sel:
                log.info("Tag settings only work with a selected item")
                return

            if sel.is_tag:
                tag = sel
            else:
                tag = sel.parent_tag

            conf = { "tag" : self.callbacks["get_tag_conf"](tag.tag) }

            if val != "":
                assign_to_dict(conf, opt, val)
                self.callbacks["set_tag_conf"](tag.tag, conf["tag"])
        else:
            conf = self.callbacks["get_conf"]()

            if val != "":
                assign_to_dict(conf, opt, val)
                self.callbacks["set_conf"](conf)

        ok, val = access_dict(conf, opt)
        if not ok:
            log.error("Unknown option %s" % opt)
            log.error("Full conf: %s" % conf)
        else:
            log.info("%s = %s" % (opt, val))