Beispiel #1
0
    def get_value(self, vid, attribute=None, resolved=True, subgroup=None):
        """
        Get a value for entry with id attribute vid.
        or from the values field if the attribute argument is provided
        and matches
        """
        value = None
        vid, comp, iscompvar = self.check_if_comp_var(vid, attribute)
        logger.debug("vid {} comp {} iscompvar {}".format(vid, comp, iscompvar))
        if iscompvar:
            if comp is None:
                if subgroup is not None:
                    comp = subgroup
                else:
                    logger.debug("Not enough info to get value for {}".format(vid))
                    return value
            if attribute is None:
                attribute = {"compclass" : comp}
            else:
                attribute["compclass"] = comp
            node = self.scan_optional_child("entry", {"id":vid})
            if node is not None:
                type_str = self._get_type_info(node)
                values = self.get_optional_child("values", root=node)
                node = values if values is not None else node
                val = self.get_element_text("value", attribute, root=node)
                if val is not None:
                    if val.startswith("$"):
                        value = val
                    else:
                        value = convert_to_type(val,type_str, vid)
                return value

        return EntryID.get_value(self, vid, attribute=attribute, resolved=resolved, subgroup=subgroup)
Beispiel #2
0
    def get_value(self, vid, attribute=None, resolved=True, subgroup=None):
        """
        Get a value for entry with id attribute vid.
        or from the values field if the attribute argument is provided
        and matches
        """
        value = None
        vid, comp, iscompvar = self.check_if_comp_var(vid, attribute)
        logger.debug("vid {} comp {} iscompvar {}".format(vid, comp, iscompvar))
        if iscompvar:
            if comp is None:
                if subgroup is not None:
                    comp = subgroup
                else:
                    logger.debug("Not enough info to get value for {}".format(vid))
                    return value
            if attribute is None:
                attribute = {"compclass" : comp}
            else:
                attribute["compclass"] = comp
            node = self.scan_optional_child("entry", {"id":vid})
            if node is not None:
                type_str = self._get_type_info(node)
                values = self.get_optional_child("values", root=node)
                node = values if values is not None else node
                val = self.get_element_text("value", attribute, root=node)
                if val is not None:
                    if val.startswith("$"):
                        value = val
                    else:
                        value = convert_to_type(val,type_str, vid)
                return value

        return EntryID.get_value(self, vid, attribute=attribute, resolved=resolved, subgroup=subgroup)
Beispiel #3
0
 def get_value(self, name, attribute=None, resolved=False, subgroup=None):
     expect(subgroup is None, "This class does not support subgroups")
     return EntryID.get_value(self, name, attribute, resolved)