[PATCH 1 of 2 eac] Do not export empty "descriptiveNote" elements

Sylvain Thénault sylvain.thenault at logilab.fr
Tue Dec 19 10:51:55 CET 2017



On 18/12/2017 15:36, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde at logilab.fr>
> # Date 1513606950 -3600
> #      Mon Dec 18 15:22:30 2017 +0100
> # Node ID 0553a7429acaaba90617cddd09b50f89b3842338
> # Parent  82b5defa1894cbf0b38a20713c025a2cc1238df7
> Do not export empty "descriptiveNote" elements
>
> diff --git a/cubicweb_eac/entities.py b/cubicweb_eac/entities.py
> --- a/cubicweb_eac/entities.py
> +++ b/cubicweb_eac/entities.py
> @@ -275,8 +275,11 @@ def add_descriptive_note(func):
>      def wrapper(self, entity, *args, **kwargs):
>          element = func(self, entity, *args, **kwargs)
>          if element is not None and entity.description:
> -            self.element('descriptiveNote', parent=element).extend(
> -                self._eac_richstring_paragraph_elements(entity, "description"))
> +            description = self._eac_richstring_paragraph_elements(
> +                entity, "description")
> +            if description:
> +                self.element('descriptiveNote', parent=element).extend(
> +                    description)
>          return element
>      return wrapper
>  
>
is this really useful? It seems to me that the earlier test on
entity.description is already protecting against empty protection. If
not, the case should be demonstrated by a test.

-- 
Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse (05.62.17.16.42)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
CubicWeb, the semantic web framework:    http://www.cubicweb.org



More information about the saem-devel mailing list