예제 #1
0
def get_models():
    """
    Returns a list of all currently loaded subclasses of Model

    :return: List Model subclasses
    """
    return [model for model in get_flattened_subclasses(Model) if model is not issubclass(model, _ModelReference)]
예제 #2
0
def get_tags():
    tags = get_flattened_subclasses(Tag)
    for tag in (tag for tag in tags if tag is not Tag):
        tag_name = getattr(tag, 'name', None)
        if not tag_name:
            raise InvalidTagDefinitionError('Tag {} does not contain a tag name attribute'.format(tag))
    return tags
예제 #3
0
def get_channels():
    channels = get_flattened_subclasses(OutputOnlyChannel)
    for channel in (channel for channel in channels if channel is not Channel):
        channel_name = getattr(channel, 'name', None)
        if not channel_name:
            raise InvalidChannelDefinitionError('Channel {} does not contain a channel name attribute'.format(channel))
    return channels
예제 #4
0
파일: __init__.py 프로젝트: jhornice/leapp
def get_models():
    """
    Returns a list of all currently loaded subclasses of Model

    :return: List Model subclasses
    """
    return get_flattened_subclasses(Model)
예제 #5
0
def get_actors():
    """
    :return: All registered actors with their metadata
    """
    actors = get_flattened_subclasses(Actor)
    for actor in actors:
        get_actor_metadata(actor)
    return actors
예제 #6
0
def get_topics():
    topics = get_flattened_subclasses(Topic)
    for topic in (topic for topic in topics):
        topic_name = getattr(topic, 'name', None)
        if not topic_name:
            raise InvalidTopicDefinitionError(
                'Topic {} does not contain a name attribute'.format(topic))
    return topics
예제 #7
0
def get_tags():
    """
    :return: All registered :py:class:`leapp.tags.Tag` derived classes
    """
    tags = get_flattened_subclasses(Tag)
    for tag in (tag for tag in tags if tag is not Tag):
        tag_name = getattr(tag, 'name', None)
        if not tag_name:
            raise InvalidTagDefinitionError('Tag {} does not contain a tag name attribute'.format(tag))
    return tags
예제 #8
0
파일: __init__.py 프로젝트: bocekm/leapp
def resolve_model_references():
    """
    Resolves all dynamically created model references. When importing a model that has not been loaded
    yet, a dynamic model reference is created. After loading all models, resolve_model_references
    must be called to ensure the consistency of the code.

    :return: None
    """
    for reference in get_flattened_subclasses(_ModelReference):
        reference.resolve()
예제 #9
0
def get_topics():
    """
    :return: All registered :py:class:`leapp.topics.Topic` derived classes
    """
    topics = get_flattened_subclasses(Topic)
    for topic in (topic for topic in topics):
        topic_name = getattr(topic, 'name', None)
        if not topic_name:
            raise InvalidTopicDefinitionError(
                'Topic {} does not contain a name attribute'.format(topic))
    return topics
예제 #10
0
def test_get_flattened_subclasses():
    class BaseClass(object):
        pass

    class SubClass(BaseClass):
        pass

    class SubSubClass(SubClass):
        pass

    class SubSubSubClass(SubSubClass):
        pass

    classes = get_flattened_subclasses(BaseClass)
    assert len(classes) == 3
    assert SubClass in classes
    assert SubSubClass in classes
    assert SubSubSubClass in classes
예제 #11
0
def get_workflows():
    """
    :return: all registered workflows
    """
    return get_flattened_subclasses(Workflow)
예제 #12
0
def get_actors():
    actors = get_flattened_subclasses(Actor)
    for actor in actors:
        get_actor_metadata(actor)
    return actors
예제 #13
0
def get_workflows():
    return get_flattened_subclasses(Workflow)
예제 #14
0
def get_models():
    return get_flattened_subclasses(Model)