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

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