(topicName: str)
Raise TopicNameError if nameTuple not valid as topic name.
Raise TopicNameError if nameTuple not valid as topic name.
Raise TopicNameError if nameTuple not valid as topic name .
def validateName(topicName: str):
    """Raise TopicNameError if nameTuple not valid as topic name."""
    topicNameTuple = tupleize(topicName)
    if not topicNameTuple:
        reason = 'name tuple must have at least one item!'
        raise TopicNameError(None, reason)

    class topic:
        pass

    for subname in topicNameTuple:
        if not subname:
            reason = 'can\'t contain empty string or None'
            raise TopicNameError(topicNameTuple, reason)

        if subname.startswith(UNDERSCORE):
            reason = 'must not start with "%s"' % UNDERSCORE
            raise TopicNameError(topicNameTuple, reason)

        if subname == ALL_TOPICS:
            reason = 'string "%s" is reserved for root topic' % ALL_TOPICS
            raise TopicNameError(topicNameTuple, reason)

        if _validNameRE.match(subname) is None:
            reason = 'element #%s ("%s") has invalid characters' % \
                     (1 + list(topicNameTuple).index(subname), subname)
            raise TopicNameError(topicNameTuple, reason)
def validateName ( topicName : str ) : topicNameTuple = tupleize ( topicName ) if not topicNameTuple : reason = 'name tuple must have at least one item!' raise TopicNameError ( None , reason ) class topic : pass for subname in topicNameTuple : if not subname : reason = 'can\'t contain empty string or None' raise TopicNameError ( topicNameTuple , reason ) if subname . startswith ( UNDERSCORE ) : reason = 'must not start with "%s"' % UNDERSCORE raise TopicNameError ( topicNameTuple , reason ) if subname == ALL_TOPICS : reason = 'string "%s" is reserved for root topic' % ALL_TOPICS raise TopicNameError ( topicNameTuple , reason ) if _validNameRE . match ( subname ) is None : reason = 'element #%s ("%s") has invalid characters' % ( 1 + list ( topicNameTuple ) . index ( subname ) , subname ) raise TopicNameError ( topicNameTuple , reason )