From c126922ecdff42e2e5a388ad3a11bd6031148993 Mon Sep 17 00:00:00 2001 From: Yann Date: Fri, 11 Sep 2015 12:25:01 +0200 Subject: [PATCH] Cleaning EmType.superiors() comments and variable name --- EditorialModel/types.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/EditorialModel/types.py b/EditorialModel/types.py index 20f72d7..81adde1 100644 --- a/EditorialModel/types.py +++ b/EditorialModel/types.py @@ -188,22 +188,19 @@ class EmType(EmComponent): def subordinates(self): return { nature: [ self.model.component(tuid) for tuid in self.subordinates_list[nature] ] for nature in self.subordinates_list } - ## @brief Get the list of subordinates EmType - # Get a list of EmType instance that have this EmType for superior - # @return Return a dict with relation nature as keys and values as a list of subordinates - # EmType instance - # @throw RuntimeError if a nature fetched from db is not valid - # @see EmType::_sub_or_sup() - # @todo reimplementation needed + ## @brief Get the list of superiors by relation's nature + # Get a list of EmType that are superiors of this type + # @return Return a dict with relation nature as keys and an EmType as value + # @throw RuntimeError if a nature has multiple superiors def superiors(self): superiors = {} for em_type in self.model.components(EmType): - for nature, field_uids in em_type.subordinates_list.items(): - if self.uid in field_uids: + for nature, sub_uids in em_type.subordinates_list.items(): + if self.uid in sub_uids: if nature in superiors: - superiors[nature].append(em_type) + raise RuntimeError("Multiple superiors found for relation of nature '%s' for EmType %d"%(nature, self.uid)) else: - superiors[nature] = [em_type] + superiors[nature] = em_type return superiors ## Add a superior in the type hierarchy