[libvirt] [PATCH python 08/15] generator: Sort enums and functions when generating code

Doug Goldstein cardoe at gentoo.org
Tue Dec 3 17:05:33 UTC 2013


On Tue, Dec 3, 2013 at 10:36 AM, Daniel P. Berrange <berrange at redhat.com> wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
>
> To assist in diff comparisons between code generated with
> different versions of Python, do an explicit sort of all
> functions and enums.
>
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---
>  generator.py | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/generator.py b/generator.py
> index af05d7c..17f00d6 100755
> --- a/generator.py
> +++ b/generator.py
> @@ -865,7 +865,10 @@ def buildStubs(module, api_xml):
>      wrapper.write("#include \"typewrappers.h\"\n")
>      wrapper.write("#include \"build/" + module + ".h\"\n\n")
>
> -    for function in list(funcs.keys()):
> +    funcnames = list(funcs.keys())
> +    if funcnames is not None:
> +        funcnames.sort()
> +    for function in funcnames:
>          # Skip the functions which are not for the module
>          ret = print_function_wrapper(module, function, wrapper, export, include)
>          if ret < 0:
> @@ -1758,7 +1761,10 @@ def buildWrappers(module):
>      #
>      # Generate enum constants
>      #
> -    for type,enum in list(enums.items()):
> +    enumvals = list(enums.items())
> +    if enumvals is not None:
> +        enumvals.sort(key=lambda x: x[0])
> +    for type,enum in enumvals:
>          classes.write("# %s\n" % type)
>          items = list(enum.items())
>          items.sort(key=lambda i: int(i[1]))
> --
> 1.8.3.1

ACK.

-- 
Doug Goldstein




More information about the libvir-list mailing list