[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [XEN PATCH 2/3] read a grubenv file if it is next to the grub.cfg file



YOUNG, MICHAEL A. writes ("[XEN PATCH 2/3] read a grubenv file if it is next to 
the grub.cfg file"):
> When a grub.cfg file is found this patch checks if there is grubenv
> file in the same directory as the grub.cfg file. If there is it
> passes the contents to parse().

I am happy with the semantics of this patch.  But I am not really
happy with the duplication of the code to call self.cf.parse, so that
it is now quadriplicated.

> +        if fenv != "" and fs.file_exists(fenv):
> +            fenvf = fs.open_file(fenv)
> +            grubenv = fenvf.read(FS_READ_MAX)
> +            del fenvf
> +            if sys.version_info[0] < 3:
> +                self.cf.parse(buf, grubenv)
> +            else:
> +                self.cf.parse(buf.decode(), grubenv.decode())
> +        else:
> +            if sys.version_info[0] < 3:
> +                self.cf.parse(buf)
> +            else:
> +                self.cf.parse(buf.decode())

Can you please do something like

   grubenv = None
   if fenv ...
       ...

   if grubenv is not None and sys.version_info[0] < 3:
       grubenv = grubenv.decode()

and then you could at least avoid further multiplications of the call
to .parse...

Thanks,
Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.