(self, treeConfig: TreeConfig, nameTuple: Tuple[str, ...], description: str,
                 msgArgsInfo: ArgsInfo, parent: Topic = None)
Create a topic. Should only be called by TopicManager via its
        getOrCreateTopic() method (which gets called in several places
        in pubsub, such as sendMessage, subscribe, and newTopic).

        :param treeConfig: topic tree configuration settings
        :param nameTuple: topic name, in tuple format (no dots)
        :param description: "docstring" for topic
        :param ArgsInfo msgArgsInfo: object that defines MDS for topic
        :param parent: parent of topic

        :raises ValueError: invalid topic name
Create a topic. Should only be called by TopicManager via its
        getOrCreateTopic() method (which gets called in several places
        in pubsub, such as sendMessage, subscribe, and newTopic).
Create a topic . Should only be called by TopicManager via its getOrCreateTopic () method ( which gets called in several places in pubsub such as sendMessage subscribe and newTopic ) .
def __init__(self, treeConfig: TreeConfig, nameTuple: Tuple[str, ...], description: str,
                 msgArgsInfo: ArgsInfo, parent: Topic = None):
        """
        Create a topic. Should only be called by TopicManager via its
        getOrCreateTopic() method (which gets called in several places
        in pubsub, such as sendMessage, subscribe, and newTopic).

        :param treeConfig: topic tree configuration settings
        :param nameTuple: topic name, in tuple format (no dots)
        :param description: "docstring" for topic
        :param ArgsInfo msgArgsInfo: object that defines MDS for topic
        :param parent: parent of topic

        :raises ValueError: invalid topic name
        """
        if parent is None:
            if nameTuple != (ALL_TOPICS,):
                msg = 'Only one topic, named %s, can be root of topic tree'
                raise ValueError(msg % 'pub.ALL_TOPICS')
        else:
            validateName(nameTuple)
        self.__tupleName = nameTuple

        self.__handlingUncaughtListenerExc = False
        self._treeConfig = treeConfig

        self.__validator = None
        # Registered listeners were originally kept in a Python list; however
        # a few methods require lookup of the Listener for the given callable,
        # which is an O(n) operation. A set() could have been more suitable but
        # there is no way of retrieving an element from a set without iterating
        # over the set, again an O(n) operation. A dict() is ok too. Because
        # Listener.__eq__(callable) returns true if the Listener instance wraps
        # the given callable, and because Listener.__hash__ produces the hash
        # value of the wrapped callable, calling dict[callable] on a
        # dict(Listener -> Listener) mapping will be O(1) in most cases:
        # the dict will take the callables hash, find the list of Listeners that
        # have that hash, and then iterate over that inner list to find the
        # Listener instance which satisfies Listener == callable, and will return
        # the Listener.
        self.__listeners = dict()

        # specification:
        self.__description = None
        self.setDescription(description)
        self.__msgArgs = msgArgsInfo
        if msgArgsInfo.isComplete():
            self.__finalize()
        else:
            assert not self._treeConfig.raiseOnTopicUnspecified

        # now that we know the args are fine, we can link to parent
        self.__parentTopic = None
        self.__subTopics = {}
        if parent is None:
            assert self.hasMDS()
        else:
            self.__parentTopic = weakref(parent)
            assert self.__msgArgs.parentAI() is parent.__msgArgs
            parent.__adoptSubtopic(self)
def __init__ ( self , treeConfig : TreeConfig , nameTuple : Tuple [ str , ... ] , description : str , msgArgsInfo : ArgsInfo , parent : Topic = None ) : if parent is None : if nameTuple != ( ALL_TOPICS , ) : msg = 'Only one topic, named %s, can be root of topic tree' raise ValueError ( msg % 'pub.ALL_TOPICS' ) else : validateName ( nameTuple ) self . __tupleName = nameTuple self . __handlingUncaughtListenerExc = False self . _treeConfig = treeConfig self . __validator = None # Registered listeners were originally kept in a Python list; however # a few methods require lookup of the Listener for the given callable, # which is an O(n) operation. A set() could have been more suitable but # there is no way of retrieving an element from a set without iterating # over the set, again an O(n) operation. A dict() is ok too. Because # Listener.__eq__(callable) returns true if the Listener instance wraps # the given callable, and because Listener.__hash__ produces the hash # value of the wrapped callable, calling dict[callable] on a # dict(Listener -> Listener) mapping will be O(1) in most cases: # the dict will take the callables hash, find the list of Listeners that # have that hash, and then iterate over that inner list to find the # Listener instance which satisfies Listener == callable, and will return # the Listener. self . __listeners = dict ( ) # specification: self . __description = None self . setDescription ( description ) self . __msgArgs = msgArgsInfo if msgArgsInfo . isComplete ( ) : self . __finalize ( ) else : assert not self . _treeConfig . raiseOnTopicUnspecified # now that we know the args are fine, we can link to parent self . __parentTopic = None self . __subTopics = { } if parent is None : assert self . hasMDS ( ) else : self . __parentTopic = weakref ( parent ) assert self . __msgArgs . parentAI ( ) is parent . __msgArgs parent . __adoptSubtopic ( self )