2c934879d6
- Add patches to fix tests when using python3: * graphite2-python3_tests.patch * graphite2-python3_tests_cornercases.patch - Refresh all other patches - Use fancy name for downloaded tarball - Run spec-cleaner OBS-URL: https://build.opensuse.org/request/show/543870 OBS-URL: https://build.opensuse.org/package/show/LibreOffice:Factory/graphite2?expand=0&rev=50
99 lines
3.6 KiB
Diff
99 lines
3.6 KiB
Diff
From d96d572627cde920af9044e0b6386e2edf56e767 Mon Sep 17 00:00:00 2001
|
|
From: Tim Eves <tim_eves@sil.org>
|
|
Date: Wed, 2 Aug 2017 12:18:11 +0700
|
|
Subject: [PATCH] Make python test programs python2 & 3 compatible
|
|
|
|
---
|
|
tests/fnttxtrender | 11 ++++++++---
|
|
tests/graphite.py | 13 +++++++++----
|
|
2 files changed, 17 insertions(+), 7 deletions(-)
|
|
|
|
Index: graphite-1.3.10/tests/fnttxtrender
|
|
===================================================================
|
|
--- graphite-1.3.10.orig/tests/fnttxtrender
|
|
+++ graphite-1.3.10/tests/fnttxtrender
|
|
@@ -1,5 +1,11 @@
|
|
#!/usr/bin/python
|
|
|
|
+from __future__ import print_function, unicode_literals
|
|
+try:
|
|
+ import itertools.imap as map
|
|
+except ImportError:
|
|
+ pass
|
|
+
|
|
import codecs
|
|
from optparse import OptionParser
|
|
from difflib import SequenceMatcher
|
|
@@ -202,7 +208,7 @@ rounding = 0.1 ** opts.dp
|
|
# if --graphite_library is used.
|
|
import graphite as gr
|
|
|
|
-outfile = codecs.getwriter("utf_8")(open(opts.output, mode="wt") if opts.output else sys.stdout)
|
|
+outfile = codecs.getwriter("utf_8")(open(opts.output, mode="wb") if opts.output else sys.stdout)
|
|
|
|
if opts.compare :
|
|
with open(opts.compare) as f :
|
|
@@ -237,7 +243,7 @@ for label, words in reader :
|
|
wcount = 0
|
|
for s in words :
|
|
wcount += 1
|
|
- gls = [map(lambda x: name(tt, x, rounding), font.glyphs(s, includewidth = True))]
|
|
+ gls = [list(map(lambda x: name(tt, x, rounding), font.glyphs(s, includewidth = True)))]
|
|
if gls[-1][-1][0] is None : gls[-1] = ('_adv_', gls[-1][-1][1], gls[-1][-1][2])
|
|
l = makelabel(label, count, wcount)
|
|
if cjson is not None and cmpgls(gls[0], cjson[l][0], opts.epsilon) :
|
|
@@ -251,4 +257,3 @@ for label, words in reader :
|
|
if log is not None : log.logend()
|
|
outfile.close()
|
|
sys.exit(errors)
|
|
-
|
|
Index: graphite-1.3.10/tests/graphite.py
|
|
===================================================================
|
|
--- graphite-1.3.10.orig/tests/graphite.py
|
|
+++ graphite-1.3.10/tests/graphite.py
|
|
@@ -17,7 +17,11 @@
|
|
# suite 500, Boston, MA 02110-1335, USA or visit their web page on the
|
|
# internet at http://www.fsf.org/licenses/lgpl.html.
|
|
|
|
-
|
|
+from __future__ import print_function, unicode_literals, division, absolute_import
|
|
+try:
|
|
+ unicode
|
|
+except NameError:
|
|
+ unicode = str
|
|
from ctypes import *
|
|
import ctypes.util
|
|
import sys, os, platform
|
|
@@ -181,6 +185,7 @@ class FeatureRef(object) :
|
|
|
|
class Face(object) :
|
|
def __init__(self, data, options = 0, fn=None, segcache=0) :
|
|
+ data = data.encode('utf8')
|
|
if fn :
|
|
if segcache :
|
|
self.face = gr2.gr_make_face_with_seg_cache(data, fn, segcache, options)
|
|
@@ -202,12 +207,12 @@ class Face(object) :
|
|
return gr2.fr_face_n_glyphs(self.face)
|
|
|
|
def get_featureval(self, lang) :
|
|
- if isinstance(lang, basestring) :
|
|
+ if isinstance(lang, bytes) :
|
|
lang = gr_str_to_tag(lang)
|
|
return FeatureVal(gr2.gr_face_featureval_for_lang(self.face, lang))
|
|
|
|
def get_featureref(self, featid) :
|
|
- if isinstance(featid, basestring) :
|
|
+ if isinstance(featid, bytes) :
|
|
featid = gr_str_to_tag(featid)
|
|
return FeatureRef(gr2.gr_face_find_fref(self.face, featid))
|
|
|
|
@@ -320,7 +325,7 @@ class Segment(object) :
|
|
def __init__(self, font, face, scriptid, string, rtl, length = None, feats = None) :
|
|
if not length :
|
|
length = len(string)
|
|
- if isinstance(scriptid, basestring) :
|
|
+ if isinstance(scriptid, bytes) :
|
|
scriptid = gr2.gr_str_to_tag(scriptid)
|
|
self.seg = gr2.gr_make_seg(font.font if font is not None else 0, face.face, scriptid, (feats.fval if feats else 0), 1, string.encode('utf_8'), length, rtl)
|
|
|