Beispiel #1
0
    def get_children(self, name=None, attributes=None, root=None):
        if self.locked and name == "entry" and attributes is not None and attributes.keys(
        ) == ["id"]:
            entry_id = attributes["id"]
            if root is None or self.name(root) == "file":
                if entry_id in self._id_map:
                    return self._id_map[entry_id]
                else:
                    return []
            else:
                expect(
                    self.name(root) == "group",
                    "Unexpected elem '{}' for {}, attrs {}".format(
                        self.name(root), self.filename, self.attrib(root)))
                group_id = self.get(root, "id")
                if group_id in self._group_map and entry_id in self._group_map[
                        group_id]:
                    return [self._group_map[group_id][entry_id]]
                else:
                    return []

        else:
            # Non-compliant look up
            return EntryID.get_children(self,
                                        name=name,
                                        attributes=attributes,
                                        root=root)
Beispiel #2
0
    def get_children(self, name=None, attributes=None, root=None):
        if self.locked and name == "entry" and attributes is not None and attributes.keys() == ["id"]:
            entry_id = attributes["id"]
            if root is None or self.name(root) == "file":
                if entry_id in self._id_map:
                    return self._id_map[entry_id]
                else:
                    return []
            else:
                expect(self.name(root) == "group", "Unexpected elem '{}' for {}, attrs {}".format(self.name(root), self.filename, self.attrib(root)))
                group_id = self.get(root, "id")
                if group_id in self._group_map and entry_id in self._group_map[group_id]:
                    return [self._group_map[group_id][entry_id]]
                else:
                    return []

        else:
            # Non-compliant look up
            return EntryID.get_children(self, name=name, attributes=attributes, root=root)