Exemple #1
0
    def remove_topic(self, name):
        if "/" in name:
            root, nodes = name.split("/", 1)
            _topic = self.get_topic(root)

            if _topic is not None:
                return _topic.remove_topic(nodes)
            raise UnknownTopicException("Unknown topic: %s" % name)
        else:
            _topic = self.get_topic(name)

            if _topic is not None:
                del _topic.parent
                del self.topics[name]
                return True
            raise UnknownTopicException("Unknown topic: %s" % name)
Exemple #2
0
    def remove_topic(self, name):
        if "/" in name:
            root, nodes = name.split("/", 1)

            _topic = self.get_topic(root)

            if _topic is not None:
                return _topic.remove_topic(nodes)
            raise UnknownTopicException("Unknown topic: %s" % name)
        else:
            _topic = self.get_topic(name)

            if _topic is not None:
                if _topic.parent:
                    del _topic.parent

                del self.topics[name]

                if _topic.type == HelpTopicType.CommandTopic:
                    if _topic.root in self.commands:
                        del self.commands[_topic]

                return True
            raise UnknownTopicException("Unknown topic: %s" % name)
Exemple #3
0
    def add_topic(self, name, topic):
        if "/" in name:
            root, nodes = name.split("/", 1)
            _topic = self.get_topic(root)

            if _topic is not None:
                return _topic.add_topic(nodes, topic)
            raise UnknownTopicException("Unknown topic: %s" % name)
        else:
            _topic = self.get_topic(name)

            if _topic is None:
                topic.parent = self
                self.topics[name] = topic
                return True
            return False