Example #1
0
def importTopicTree(source, format = TOPIC_TREE_FROM_MODULE, lazy=False):
    '''Import topic definitions from a source. The format of the
    source defaults to TOPIC_TREE_FROM_MODULE, ie default is to import
    from a module (typically, exported by exportTopicTree(source).
    The doc string for the source is returned (for a module source, this
    is the module doc string; etc). If lazy is True, the topics will be
    put in topic tree only upon first use by the application, otherwise,
    all topics that don't already exist are incorporated (this may result
    in a smaller topic tree if an application has evolved significantly).
    
    Other source formats are TOPIC_TREE_FROM_STRING and
    TOPIC_TREE_FROM_CLASS. They are explained in the package API
    documentation.
    
    Notes: 
    - This function can be called several times, but should be called
      only once per source.
    - More source formats can be defined via
      pub.registerTopicDefnProviderType(), which must be given a class
      that adheres to the pub.ITopicDefnProvider interface.
    - If lazy=True, then a later call to exportTopicTree() will only
      export those topics that have been used by the application 
    '''
    provider = TopicDefnProvider(source, format)
    addTopicDefnProvider(provider)
    if not lazy:
        for topicName in provider:
            _topicMgr.getOrCreateTopic(topicName)

    return provider.getTreeDoc()
Example #2
0
def importTopicTree(source, format=TOPIC_TREE_FROM_MODULE, lazy=False):
    '''Import topic definitions from a source. The format of the
    source defaults to TOPIC_TREE_FROM_MODULE, ie default is to import
    from a module (typically, exported by exportTopicTree(source).
    The doc string for the source is returned (for a module source, this
    is the module doc string; etc). If lazy is True, the topics will be
    put in topic tree only upon first use by the application, otherwise,
    all topics that don't already exist are incorporated (this may result
    in a smaller topic tree if an application has evolved significantly).
    
    Other source formats are TOPIC_TREE_FROM_STRING and
    TOPIC_TREE_FROM_CLASS. They are explained in the package API
    documentation.
    
    Notes: 
    - This function can be called several times, but should be called
      only once per source.
    - More source formats can be defined via
      pub.registerTopicDefnProviderType(), which must be given a class
      that adheres to the pub.ITopicDefnProvider interface.
    - If lazy=True, then a later call to exportTopicTree() will only
      export those topics that have been used by the application 
    '''
    provider = TopicDefnProvider(source, format)
    addTopicDefnProvider(provider)
    if not lazy:
        for topicName in provider:
            _topicMgr.getOrCreateTopic(topicName)

    return provider.getTreeDoc()
Example #3
0
def importTopicTree(source, format = TOPIC_TREE_FROM_CLASS, lazy=False, **providerKwargs):
    '''Import topic definitions. The source contains the definitions and can be one of 
    several types (module, class, string), indicated by the "format" parameter. If lazy 
    is True, all topics defined in source get instantiated even if not used by the 
    application. The providerKwargs are given vertabim to the TopicDefnProvider that 
    is used by this function. 
    '''
    provider = TopicDefnProvider(source, format, **providerKwargs)
    addTopicDefnProvider(provider)
    if not lazy:
        for topicName in provider:
            _topicMgr.getOrCreateTopic(topicName)

    return provider.getTreeDoc()
Example #4
0
def importTopicTree(source,
                    format=TOPIC_TREE_FROM_CLASS,
                    lazy=False,
                    **providerKwargs):
    '''Import topic definitions. The source contains the definitions and can be one of 
    several types (module, class, string), indicated by the "format" parameter. If lazy 
    is True, all topics defined in source get instantiated even if not used by the 
    application. The providerKwargs are given vertabim to the TopicDefnProvider that 
    is used by this function. 
    '''
    provider = TopicDefnProvider(source, format, **providerKwargs)
    addTopicDefnProvider(provider)
    if not lazy:
        for topicName in provider:
            _topicMgr.getOrCreateTopic(topicName)

    return provider.getTreeDoc()