Example #1
0
    def _get_choices(self, id):
        names = []
        values = []
        default = None

        for opt in self._ptree.xpath("//select[@name='{}']/option".format(id)):
            n = opt.text or ""
            v = opt.attrib.get("value")
            v = n if v is None else v
            names.append(n.strip())
            values.append(v)
            if opt.attrib.get("selected") is not None:
                default = n

        o = OrderedDict(zip(names, values))
        o.default = default
        return o
Example #2
0
    def platforms(self):
        if "platforms" in self:
            return self["platforms"]

        self["platforms"] = OrderedDict()
        self["platforms"].default = "avr"

        if self.use_arduino15_dirs():
            for arch in ["sam", "avr"]:
                platform_txt = self.find_arduino_file(
                    arch + "_platform.txt",
                    ["hardware", "arduino", arch],
                    items=["platform.txt"],
                    human_name="Platform description file (%s/platform.txt)" % arch,
                )
                self["platforms"][arch] = ArduinoData()
                self["platforms"][arch].parse(platform_txt)

        return self["platforms"]