diff --git a/tiramisu/config.py b/tiramisu/config.py index fd76f6e..8384bc4 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -248,7 +248,7 @@ class SubConfig(BaseInformation): _subpath=self.cfgimpl_get_path()) def find_first(self, bytype=None, byname=None, byvalue=None, - type_='option'): + type_='option', display_error=True): """ finds an option recursively in the config @@ -260,10 +260,11 @@ class SubConfig(BaseInformation): return self.cfgimpl_get_context()._find(bytype, byname, byvalue, first=True, type_=type_, - _subpath=self.cfgimpl_get_path()) + _subpath=self.cfgimpl_get_path(), + display_error=display_error) def _find(self, bytype, byname, byvalue, first, type_='option', - _subpath=None, check_properties=True): + _subpath=None, check_properties=True, display_error=True): """ convenience method for finding an option that lives only in the subtree @@ -346,9 +347,10 @@ class SubConfig(BaseInformation): else: find_results.append(retval) if find_results == []: - #FIXME too slow - #raise AttributeError(_("no option found in config with these criteria")) - raise AttributeError("no option found in config with these criteria") + if display_error: + raise AttributeError(_("no option found in config with these criteria")) + else: + raise AttributeError() else: return find_results @@ -568,7 +570,8 @@ class MetaConfig(CommonConfig): except PropertiesOptionError: pass - def find_first_contexts(self, byname=None, bypath=None, byvalue=None, type_='context'): + def find_first_contexts(self, byname=None, bypath=None, byvalue=None, + type_='context', display_error=True): ret = [] try: if bypath is None and byname is not None and \ @@ -592,12 +595,14 @@ class MetaConfig(CommonConfig): else: ret.append(child.find_first(byname=byname, byvalue=byvalue, - type_=type_)) + type_=type_, + display_error=False)) else: ret.extend(child.find_first_contexts(byname=byname, bypath=bypath, byvalue=byvalue, - type_=type_)) + type_=type_, + display_error=False)) except AttributeError: pass return ret diff --git a/translations/fr/tiramisu.po b/translations/fr/tiramisu.po index e11019c..3ef5ce3 100644 --- a/translations/fr/tiramisu.po +++ b/translations/fr/tiramisu.po @@ -26,8 +26,8 @@ msgid "" "unable to carry out a calculation, option value with multi types must have " "same length for: {0}" msgstr "" -"impossible d'effectuer le calcul, valeur d'un option avec le type multi " -"doit avoir la même longueur pour : {0}" +"impossible d'effectuer le calcul, valeur d'un option avec le type multi doit " +"avoir la même longueur pour : {0}" #: tiramisu/config.py:45 msgid "descr must be an optiondescription, not {0}" @@ -397,3 +397,7 @@ msgstr "ne peut étendre une option multi {0} pour une maître ou une esclave" #: tiramisu/value.py:381 msgid "cannot pop a value on a multi option {0} which is a slave" msgstr "ne peut supprimer une valeur dans l'option multi {0} qui est esclave" + +#: tiramisu/config.py:351 +msgid "no option found in config with these criteria" +msgstr "aucune option trouvée dans la config avec ces critères"