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)]
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
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
def get_models(): """ Returns a list of all currently loaded subclasses of Model :return: List Model subclasses """ return get_flattened_subclasses(Model)
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
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
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
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()
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
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
def get_workflows(): """ :return: all registered workflows """ return get_flattened_subclasses(Workflow)
def get_actors(): actors = get_flattened_subclasses(Actor) for actor in actors: get_actor_metadata(actor) return actors
def get_workflows(): return get_flattened_subclasses(Workflow)
def get_models(): return get_flattened_subclasses(Model)