def get_block_groups(self): return list( set( filter(lambda x: x is not None, [ get_attrib_default(block.xml, "group", None) for block in self.blocks ])))
def parse_dl_settings(self, element): name = get_attrib_default(element, "name", None) group = PprzSettingsGrp(name) for child in element.getchildren(): if child.tag == "dl_settings": setting_group = self.parse_dl_settings(child) group.groups_list.append(setting_group) elif child.tag == "dl_setting": setting = self.parse_dl_setting(child) group.settings_list.append(setting) else: raise Exception("tag {} not supported!".format(child.tag)) return group
def parse_dl_setting(self, element): var = get_attrib(element, "var") min_v = get_attrib(element, "min", typ=float) max_v = get_attrib(element, "max", typ=float) shortname = get_attrib_default(element, "shortname", var) step = get_attrib_default(element, "step", 1, typ=float) values = get_attrib_default(element, "values", None) if values is None: values = [] else: values = values.split("|") count = int((max_v - min_v + step) / step) if len(values) != count: print( "Warning: possibly wrong number of values ({}) for {} (expected {})" .format(len(values), shortname, count)) setting = PprzSetting(var, self.setting_nb, shortname, min_v, max_v, step, values, element) for e_button in element.findall("strip_button"): name = get_attrib(e_button, "name") value = get_attrib(e_button, "value") icon = get_attrib_default(e_button, "icon", None) group = get_attrib_default(e_button, "group", None) button = StripButton(value, name, icon, group) setting.buttons.append(button) for e_key in element.findall("key_press"): key = get_attrib(e_key, "key") value = get_attrib(e_key, "value") key_press = KeyPress(key, value) setting.key_press.append(key_press) self.setting_nb += 1 return setting
def parse_waypoints(ways_elt: etree.Element): waypoints = [] w_no = 1 # first waypoint number is 1. for way_e in ways_elt.findall("waypoint"): name = get_attrib(way_e, "name") x = get_attrib_default(way_e, "x", None, float) y = get_attrib_default(way_e, "y", None, float) lat = get_attrib_default(way_e, "lat", None) lon = get_attrib_default(way_e, "lon", None) alt = get_attrib_default(way_e, "alt", None, float) height = get_attrib_default(way_e, "height", None, float) waypoint = Waypoint(name, x, y, lat, lon, alt, height, w_no) waypoints.append(waypoint) w_no += 1 return waypoints
def get_blocks_from_group(self, groupname): return list(filter(lambda block: get_attrib_default(block.xml, "group", None) == groupname, self.blocks))