Blame SOURCES/0002-Do-not-use-Python-version-3.patch

54c016
From ac19a179deba767a6edafc8477ae168652039f5e Mon Sep 17 00:00:00 2001
54c016
From: Richard Hughes <richard@hughsie.com>
54c016
Date: Wed, 6 Jun 2018 12:10:59 +0100
54c016
Subject: [PATCH 2/4] Do not use Python version 3
54c016
54c016
---
54c016
 contrib/firmware-packager/firmware-packager |  2 +-
54c016
 data/installed-tests/hardware.py            |  2 +-
54c016
 libfwupd/generate-version-script.py         |  2 +-
54c016
 po/make-images                              | 23 +++++++++++----------
54c016
 po/test-deps                                |  2 +-
54c016
 5 files changed, 16 insertions(+), 15 deletions(-)
54c016
54c016
diff --git a/contrib/firmware-packager/firmware-packager b/contrib/firmware-packager/firmware-packager
54c016
index 23e543ce..23658e6c 100755
54c016
--- a/contrib/firmware-packager/firmware-packager
54c016
+++ b/contrib/firmware-packager/firmware-packager
54c016
@@ -1,4 +1,4 @@
54c016
-#!/usr/bin/env python3
54c016
+#!/usr/bin/env python
54c016
 #
54c016
 # Copyright (C) 2017 Max Ehrlich max.ehr@gmail.com
54c016
 #
54c016
diff --git a/data/installed-tests/hardware.py b/data/installed-tests/hardware.py
54c016
index 026b5086..d79529ce 100755
54c016
--- a/data/installed-tests/hardware.py
54c016
+++ b/data/installed-tests/hardware.py
54c016
@@ -1,4 +1,4 @@
54c016
-#!/usr/bin/python3
54c016
+#!/usr/bin/python
54c016
 # pylint: disable=wrong-import-position,too-many-locals,unused-argument,wrong-import-order
54c016
 #
54c016
 # Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
54c016
diff --git a/libfwupd/generate-version-script.py b/libfwupd/generate-version-script.py
54c016
index a2dff9ba..e94c16c2 100755
54c016
--- a/libfwupd/generate-version-script.py
54c016
+++ b/libfwupd/generate-version-script.py
54c016
@@ -1,4 +1,4 @@
54c016
-#!/usr/bin/env python3
54c016
+#!/usr/bin/env python
54c016
 # pylint: disable=invalid-name,missing-docstring
54c016
 #
54c016
 # Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
54c016
diff --git a/po/make-images b/po/make-images
54c016
index 9f5bd4bc..de9254f7 100755
54c016
--- a/po/make-images
54c016
+++ b/po/make-images
54c016
@@ -1,4 +1,4 @@
54c016
-#!/usr/bin/env python3
54c016
+#!/usr/bin/env python
54c016
 """ This thing rasterizes text for use later """
54c016
 
54c016
 # pylint: disable=wrong-import-position,too-many-locals,unused-argument
54c016
@@ -80,11 +80,11 @@ class Rasterizer:
54c016
             PangoCairo.context_set_font_options(pctx, fo)
54c016
 
54c016
             attrs = Pango.AttrList()
54c016
-            length = len(bytes(string, "utf8"))
54c016
+            length = len(string)
54c016
             items = Pango.itemize(pctx, string, 0, length, attrs, None)
54c016
             gs = Pango.GlyphString()
54c016
             Pango.shape(string, length, items[0].analysis, gs)
54c016
-            del img, cctx, pctx, layout
54c016
+            #del img, cctx, pctx, layout
54c016
 
54c016
             def find_size(fs, f, data):
54c016
                 """ find our size, I hope... """
54c016
@@ -102,11 +102,11 @@ class Rasterizer:
54c016
             log = data['log']
54c016
             ink = data['ink']
54c016
 
54c016
-            height = math.ceil(max(ink.height, log.height) / Pango.SCALE)
54c016
-            width = math.ceil(max(ink.width, log.width) / Pango.SCALE)
54c016
+            height = int(math.ceil(max(ink.height, log.height) / Pango.SCALE))
54c016
+            width = int(math.ceil(max(ink.width, log.width) / Pango.SCALE))
54c016
 
54c016
-            x = -math.ceil(log.x / Pango.SCALE)
54c016
-            y = -math.ceil(log.y / Pango.SCALE)
54c016
+            x = int(-math.ceil(log.x / Pango.SCALE))
54c016
+            y = int(-math.ceil(log.y / Pango.SCALE))
54c016
 
54c016
             img = cairo.ImageSurface(cairo.FORMAT_RGB24, width, height)
54c016
             cctx = cairo.Context(img)
54c016
@@ -129,7 +129,7 @@ class Rasterizer:
54c016
                 tmpname = filename[len(os.environ['DESTDIR']):]
54c016
             except KeyError:
54c016
                 tmpname = filename[len(os.environ['MESON_BUILD_ROOT']):]
54c016
-            print("Writing %s                    " % (tmpname,), end='\r')
54c016
+            print("Writing %s                    " % (tmpname,))
54c016
             def make_dir(d):
54c016
                 """ make our parent dir and then our own dir """
54c016
                 if os.access(d, os.O_RDWR):
54c016
@@ -167,7 +167,9 @@ class Rasterizer:
54c016
                 nameinfo.update({'width': width,
54c016
                                  'height': height,
54c016
                                  'suffix': 'bmp'})
54c016
-                filename = self.pattern.format_map(nameinfo)
54c016
+                filename = self.pattern
54c016
+                for key in nameinfo:
54c016
+                    filename = filename.replace('{' + key + '}', str(nameinfo[key]))
54c016
                 render_one(lang, string, width, height, filename)
54c016
         print("")
54c016
 
54c016
@@ -177,7 +179,6 @@ if __name__ == '__main__':
54c016
     if len(sys.argv) != 4:
54c016
         usage(1)
54c016
 
54c016
-    label = os.fsencode(sys.argv[1]).decode('utf-8')
54c016
-    r = Rasterizer(label=label, modir=sys.argv[2],
54c016
+    r = Rasterizer(label=sys.argv[1], modir=sys.argv[2],
54c016
                    linguas=sys.argv[3])
54c016
     r.render()
54c016
diff --git a/po/test-deps b/po/test-deps
54c016
index cc8c9fd0..4d2be2da 100755
54c016
--- a/po/test-deps
54c016
+++ b/po/test-deps
54c016
@@ -1,4 +1,4 @@
54c016
-#!/usr/bin/env python3
54c016
+#!/usr/bin/env python
54c016
 """ Check dependencies needed for rasterization """
54c016
 
54c016
 """
54c016
-- 
54c016
2.17.1
54c016