[initial-setup][PATCH] Read licence files as utf-8 encoded (#1023052)

Vratislav Podzimek vpodzime at redhat.com
Thu Oct 31 06:49:58 UTC 2013


On Wed, 2013-10-30 at 17:09 +0100, Vratislav Podzimek wrote:
> License files contain translated licenses so they are usually not ascii.
> 
> Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> ---
>  initial_setup/tui/spokes/eula.py | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/initial_setup/tui/spokes/eula.py b/initial_setup/tui/spokes/eula.py
> index 3db2029..ae2080a 100644
> --- a/initial_setup/tui/spokes/eula.py
> +++ b/initial_setup/tui/spokes/eula.py
> @@ -1,6 +1,7 @@
>  """EULA TUI spoke for the Initial Setup"""
>  
>  import gettext
> +import codecs
>  
>  from pyanaconda.ui.tui.spokes import NormalTUISpoke
>  from pyanaconda.ui.tui.simpleline.widgets import TextWidget, CheckboxWidget
> @@ -100,8 +101,10 @@ class LicenseScreen(UIScreen):
>          # read the license file and make it one long string so that it can be
>          # processed by the TextWidget to fit in the screen in a best possible
>          # way
> -        with open(self._license_file, "r") as fobj:
> -            buf = u"".join(fobj.xreadlines())
> +        buf = u""
> +        with codecs.open(self._license_file, "r", "utf-8", "ignore") as fobj:
> +            for line in fobj:
> +                buf += line
>  
>          self._window += [TextWidget(buf), ""]
I may have mentioned that the GUI code doesn't need anything like that
because the utf-8 encoded data is put into a Gtk buffer without any
concatenation on our side. 

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list