[Qemu-devel] [PATCH v2 14/54] qapi2texi: minor python code simplification

Marc-André Lureau posted 54 patches 8 years, 5 months ago
There is a newer version of this series
[Qemu-devel] [PATCH v2 14/54] qapi2texi: minor python code simplification
Posted by Marc-André Lureau 8 years, 5 months ago
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 scripts/qapi2texi.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py
index a317526e51..8b542f9fff 100755
--- a/scripts/qapi2texi.py
+++ b/scripts/qapi2texi.py
@@ -136,10 +136,9 @@ def texi_enum_value(value):
 def texi_member(member, suffix=''):
     """Format a table of members item for an object type member"""
     typ = member.type.doc_type()
-    return '@item @code{%s%s%s}%s%s\n' % (
-        member.name,
-        ': ' if typ else '',
-        typ if typ else '',
+    membertype = ': %s' % typ if typ else ''
+    return '@item @code{%s%s}%s%s\n' % (
+        member.name, membertype,
         ' (optional)' if member.optional else '',
         suffix)
 
-- 
2.14.1.146.gd35faa819


Re: [Qemu-devel] [PATCH v2 14/54] qapi2texi: minor python code simplification
Posted by Philippe Mathieu-Daudé 8 years, 5 months ago
On 08/22/2017 10:22 AM, Marc-André Lureau wrote:
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>   scripts/qapi2texi.py | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py
> index a317526e51..8b542f9fff 100755
> --- a/scripts/qapi2texi.py
> +++ b/scripts/qapi2texi.py
> @@ -136,10 +136,9 @@ def texi_enum_value(value):
>   def texi_member(member, suffix=''):
>       """Format a table of members item for an object type member"""
>       typ = member.type.doc_type()
> -    return '@item @code{%s%s%s}%s%s\n' % (
> -        member.name,
> -        ': ' if typ else '',
> -        typ if typ else '',
> +    membertype = ': %s' % typ if typ else ''
> +    return '@item @code{%s%s}%s%s\n' % (
> +        member.name, membertype,
>           ' (optional)' if member.optional else '',
>           suffix)
>   
> 

Re: [Qemu-devel] [PATCH v2 14/54] qapi2texi: minor python code simplification
Posted by Markus Armbruster 8 years, 5 months ago
Marc-André Lureau <marcandre.lureau@redhat.com> writes:

> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  scripts/qapi2texi.py | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py
> index a317526e51..8b542f9fff 100755
> --- a/scripts/qapi2texi.py
> +++ b/scripts/qapi2texi.py
> @@ -136,10 +136,9 @@ def texi_enum_value(value):
>  def texi_member(member, suffix=''):
>      """Format a table of members item for an object type member"""
>      typ = member.type.doc_type()
> -    return '@item @code{%s%s%s}%s%s\n' % (
> -        member.name,
> -        ': ' if typ else '',
> -        typ if typ else '',
> +    membertype = ': %s' % typ if typ else ''

I'd use string concatenation (': ' + typ) instead of interpolation.
Matter of taste.  Could make the change when I apply.

> +    return '@item @code{%s%s}%s%s\n' % (
> +        member.name, membertype,
>          ' (optional)' if member.optional else '',
>          suffix)

Reviewed-by: Markus Armbruster <armbru@redhat.com>

Re: [Qemu-devel] [PATCH v2 14/54] qapi2texi: minor python code simplification
Posted by Marc-André Lureau 8 years, 5 months ago
Hi

----- Original Message -----
> Marc-André Lureau <marcandre.lureau@redhat.com> writes:
> 
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >  scripts/qapi2texi.py | 7 +++----
> >  1 file changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py
> > index a317526e51..8b542f9fff 100755
> > --- a/scripts/qapi2texi.py
> > +++ b/scripts/qapi2texi.py
> > @@ -136,10 +136,9 @@ def texi_enum_value(value):
> >  def texi_member(member, suffix=''):
> >      """Format a table of members item for an object type member"""
> >      typ = member.type.doc_type()
> > -    return '@item @code{%s%s%s}%s%s\n' % (
> > -        member.name,
> > -        ': ' if typ else '',
> > -        typ if typ else '',
> > +    membertype = ': %s' % typ if typ else ''
> 
> I'd use string concatenation (': ' + typ) instead of interpolation.
> Matter of taste.  Could make the change when I apply.

Good idea

> 
> > +    return '@item @code{%s%s}%s%s\n' % (
> > +        member.name, membertype,
> >          ' (optional)' if member.optional else '',
> >          suffix)
> 
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
> 

thanks