|
|
1917f8 |
From b2c5de7835a753cad1f35db8202c4733b5fc2990 Mon Sep 17 00:00:00 2001
|
|
|
1917f8 |
From: Parag A Nemade <pnemade@fedoraproject.org>
|
|
|
1917f8 |
Date: Mon, 3 Oct 2016 12:56:29 +0530
|
|
|
1917f8 |
Subject: [PATCH] Add python3 support
|
|
|
1917f8 |
|
|
|
1917f8 |
Signed-off-by: Parag A Nemade <pnemade@fedoraproject.org>
|
|
|
1917f8 |
---
|
|
|
1917f8 |
pycontrib/FontCompare/fc/BitmapHandler.py | 20 +++++++--------
|
|
|
1917f8 |
pycontrib/FontCompare/fc/DocCompare.py | 2 +-
|
|
|
1917f8 |
pycontrib/FontCompare/fc/FontCompare.py | 2 +-
|
|
|
1917f8 |
pycontrib/FontCompare/fc/GlyphConsistency.py | 2 +-
|
|
|
1917f8 |
pycontrib/FontCompare/fontcompare | 2 +-
|
|
|
1917f8 |
pycontrib/FontCompare/unittests/unittests.py | 18 ++++++-------
|
|
|
1917f8 |
pycontrib/collab/web-test-collab.py | 2 +-
|
|
|
1917f8 |
pycontrib/even.py | 2 +-
|
|
|
1917f8 |
pycontrib/gdraw/__init__.py | 4 +--
|
|
|
1917f8 |
pycontrib/gdraw/gdraw.py | 20 +++++++--------
|
|
|
1917f8 |
pycontrib/graphicore.py | 4 +--
|
|
|
1917f8 |
pycontrib/graphicore/ipython_view.py | 13 +++++-----
|
|
|
1917f8 |
pycontrib/graphicore/shell.py | 4 +--
|
|
|
1917f8 |
pycontrib/svg2sfd.py | 38 ++++++++++++++--------------
|
|
|
1917f8 |
pycontrib/webcollab.py | 6 ++---
|
|
|
1917f8 |
15 files changed, 70 insertions(+), 69 deletions(-)
|
|
|
1917f8 |
|
|
|
1917f8 |
diff --git a/pycontrib/FontCompare/fc/BitmapHandler.py b/pycontrib/FontCompare/fc/BitmapHandler.py
|
|
|
1917f8 |
index d4d00da..c159128 100644
|
|
|
1917f8 |
--- a/pycontrib/FontCompare/fc/BitmapHandler.py
|
|
|
1917f8 |
+++ b/pycontrib/FontCompare/fc/BitmapHandler.py
|
|
|
1917f8 |
@@ -35,7 +35,7 @@ def white_bg_square(img):
|
|
|
1917f8 |
"return a white-background-color image having the img in exact center"
|
|
|
1917f8 |
size = (max(img.size),)*2
|
|
|
1917f8 |
layer = Image.new('1', size, 1)
|
|
|
1917f8 |
- layer.paste(img, tuple(map(lambda x:(x[0]-x[1])/2, zip(size, img.size))))
|
|
|
1917f8 |
+ layer.paste(img, tuple([(x[0]-x[1])/2 for x in zip(size, img.size)]))
|
|
|
1917f8 |
return layer
|
|
|
1917f8 |
|
|
|
1917f8 |
class BitmapCompare:
|
|
|
1917f8 |
@@ -73,13 +73,13 @@ class CreateSpriteSheet:
|
|
|
1917f8 |
#seperate each image with lots of whitespace
|
|
|
1917f8 |
master_height = pixelsize
|
|
|
1917f8 |
oldfont = font
|
|
|
1917f8 |
- print "the master image will by %d by %d" % (master_width, master_height)
|
|
|
1917f8 |
- print "creating image..."
|
|
|
1917f8 |
+ print("the master image will by %d by %d" % (master_width, master_height))
|
|
|
1917f8 |
+ print("creating image...")
|
|
|
1917f8 |
master = Image.new(
|
|
|
1917f8 |
mode='1',
|
|
|
1917f8 |
size=(master_width, master_height),
|
|
|
1917f8 |
color=0) # fully transparent
|
|
|
1917f8 |
- print "created."
|
|
|
1917f8 |
+ print("created.")
|
|
|
1917f8 |
if effects == "italic":
|
|
|
1917f8 |
font.selection.all()
|
|
|
1917f8 |
font = font.italicize(-13)
|
|
|
1917f8 |
@@ -92,16 +92,16 @@ class CreateSpriteSheet:
|
|
|
1917f8 |
font[i].changeWeight(50,"auto",0,0,"auto")
|
|
|
1917f8 |
font[i].export("temp.bmp",pixelsize,1)
|
|
|
1917f8 |
img = Image.open("temp.bmp")
|
|
|
1917f8 |
- print "adding %s at %d..." % (str(i)+".bmp", location),
|
|
|
1917f8 |
+ print("adding %s at %d..." % (str(i)+".bmp", location), end=' ')
|
|
|
1917f8 |
square_one = white_bg_square(img)
|
|
|
1917f8 |
square_one.resize((pixelsize, pixelsize))
|
|
|
1917f8 |
master.paste(square_one,(location,0))
|
|
|
1917f8 |
- print "added."
|
|
|
1917f8 |
+ print("added.")
|
|
|
1917f8 |
except:
|
|
|
1917f8 |
- print "ooopsy"
|
|
|
1917f8 |
+ print("ooopsy")
|
|
|
1917f8 |
count+=1
|
|
|
1917f8 |
- print "done adding pics."
|
|
|
1917f8 |
- print "saving mastersprite.bmp..."
|
|
|
1917f8 |
+ print("done adding pics.")
|
|
|
1917f8 |
+ print("saving mastersprite.bmp...")
|
|
|
1917f8 |
master.save('data/mastersprite'+effects+'.bmp' )
|
|
|
1917f8 |
- print "saved!"
|
|
|
1917f8 |
+ print("saved!")
|
|
|
1917f8 |
font.close()
|
|
|
1917f8 |
diff --git a/pycontrib/FontCompare/fc/DocCompare.py b/pycontrib/FontCompare/fc/DocCompare.py
|
|
|
1917f8 |
index 3a54bf9..df431e2 100644
|
|
|
1917f8 |
--- a/pycontrib/FontCompare/fc/DocCompare.py
|
|
|
1917f8 |
+++ b/pycontrib/FontCompare/fc/DocCompare.py
|
|
|
1917f8 |
@@ -41,7 +41,7 @@ class DocCompare:
|
|
|
1917f8 |
bashcommand = "hb-view --output-format=\"png\" --output-file=\"/var/tmp/test.png\" --font-size="+str(fontsize)+" --text-file=\""
|
|
|
1917f8 |
bashcommand+=docpath+"\" "+"\""+testpath+"\""
|
|
|
1917f8 |
os.system(str(bashcommand))
|
|
|
1917f8 |
- print bashcommand
|
|
|
1917f8 |
+ print(bashcommand)
|
|
|
1917f8 |
thefile = pkg_resources.resource_filename("fc",mockfont.highresdocfile)
|
|
|
1917f8 |
shutil.copy(thefile,"/var/tmp/standard.png")
|
|
|
1917f8 |
cm = BitmapCompare()
|
|
|
1917f8 |
diff --git a/pycontrib/FontCompare/fc/FontCompare.py b/pycontrib/FontCompare/fc/FontCompare.py
|
|
|
1917f8 |
index f21718c..c82b788 100644
|
|
|
1917f8 |
--- a/pycontrib/FontCompare/fc/FontCompare.py
|
|
|
1917f8 |
+++ b/pycontrib/FontCompare/fc/FontCompare.py
|
|
|
1917f8 |
@@ -111,7 +111,7 @@ class FontCompare(object):
|
|
|
1917f8 |
scores = list()
|
|
|
1917f8 |
comparator = BitmapCompare()
|
|
|
1917f8 |
pixelsize = (resolution*ptsize)/72
|
|
|
1917f8 |
- print spritepath
|
|
|
1917f8 |
+ print(spritepath)
|
|
|
1917f8 |
for i in range (glyphRange[0],glyphRange[1]):
|
|
|
1917f8 |
if i in Testfont:
|
|
|
1917f8 |
Testfont[i].export("/var/tmp/tmp.bmp",pixelsize,1)
|
|
|
1917f8 |
diff --git a/pycontrib/FontCompare/fc/GlyphConsistency.py b/pycontrib/FontCompare/fc/GlyphConsistency.py
|
|
|
1917f8 |
index 38273c9..d5265fa 100644
|
|
|
1917f8 |
--- a/pycontrib/FontCompare/fc/GlyphConsistency.py
|
|
|
1917f8 |
+++ b/pycontrib/FontCompare/fc/GlyphConsistency.py
|
|
|
1917f8 |
@@ -102,7 +102,7 @@ class GlyphConsistency:
|
|
|
1917f8 |
for i in range (glyphrange[0],glyphrange[1]):
|
|
|
1917f8 |
if i in font:
|
|
|
1917f8 |
score = self.glyph_round_compare(font[i],pixelsize)
|
|
|
1917f8 |
- print score
|
|
|
1917f8 |
+ print(score)
|
|
|
1917f8 |
set_round_score+=score
|
|
|
1917f8 |
total+=1
|
|
|
1917f8 |
font.close()
|
|
|
1917f8 |
diff --git a/pycontrib/FontCompare/fontcompare b/pycontrib/FontCompare/fontcompare
|
|
|
1917f8 |
index e7e68d8..fdf7336 100755
|
|
|
1917f8 |
--- a/pycontrib/FontCompare/fontcompare
|
|
|
1917f8 |
+++ b/pycontrib/FontCompare/fontcompare
|
|
|
1917f8 |
@@ -15,7 +15,7 @@
|
|
|
1917f8 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
1917f8 |
"""
|
|
|
1917f8 |
|
|
|
1917f8 |
-#! /usr/bin/python
|
|
|
1917f8 |
+#! /usr/bin/python3
|
|
|
1917f8 |
from PyQt4.QtGui import QMessageBox
|
|
|
1917f8 |
from PyQt4.QtGui import QMainWindow
|
|
|
1917f8 |
from PyQt4.QtGui import QApplication
|
|
|
1917f8 |
diff --git a/pycontrib/FontCompare/unittests/unittests.py b/pycontrib/FontCompare/unittests/unittests.py
|
|
|
1917f8 |
index 18e1e95..d8a1190 100644
|
|
|
1917f8 |
--- a/pycontrib/FontCompare/unittests/unittests.py
|
|
|
1917f8 |
+++ b/pycontrib/FontCompare/unittests/unittests.py
|
|
|
1917f8 |
@@ -55,7 +55,7 @@ class Basictests(unittest.TestCase):
|
|
|
1917f8 |
for tup in basic:
|
|
|
1917f8 |
if tup[1]!=10:
|
|
|
1917f8 |
bastest=0
|
|
|
1917f8 |
- self.failUnless(bastest)
|
|
|
1917f8 |
+ self.assertTrue(bastest)
|
|
|
1917f8 |
testfont = fontforge.open("unittests/lohit.ttf")
|
|
|
1917f8 |
bold = cm.font_facecompare(testfont,mockfont,(0x900,0x97f),\
|
|
|
1917f8 |
600,12,1,"bold")
|
|
|
1917f8 |
@@ -66,28 +66,28 @@ class Basictests(unittest.TestCase):
|
|
|
1917f8 |
normal = cm.font_facecompare(testfont,mockfont,(0x900,0x97f),\
|
|
|
1917f8 |
600,12,1,"normal")
|
|
|
1917f8 |
test = 1
|
|
|
1917f8 |
- print len(normal)
|
|
|
1917f8 |
+ print(len(normal))
|
|
|
1917f8 |
for tup in bold:
|
|
|
1917f8 |
if tup[1]==100 or tup[1]==0:
|
|
|
1917f8 |
test1=1
|
|
|
1917f8 |
break
|
|
|
1917f8 |
- self.failUnless(test)
|
|
|
1917f8 |
+ self.assertTrue(test)
|
|
|
1917f8 |
test = 0
|
|
|
1917f8 |
for tup in italic:
|
|
|
1917f8 |
if tup[1]==100 or tup[1]==0:
|
|
|
1917f8 |
test=1
|
|
|
1917f8 |
break
|
|
|
1917f8 |
- self.failUnless(test is 1)
|
|
|
1917f8 |
+ self.assertTrue(test is 1)
|
|
|
1917f8 |
test = 0
|
|
|
1917f8 |
for tup in normal:
|
|
|
1917f8 |
if tup[1]==100 or tup[1]==0:
|
|
|
1917f8 |
test=1
|
|
|
1917f8 |
break
|
|
|
1917f8 |
- self.failUnless(test is 1)
|
|
|
1917f8 |
+ self.assertTrue(test is 1)
|
|
|
1917f8 |
test = 0
|
|
|
1917f8 |
if len(normal) == len(bold) == len(italic):
|
|
|
1917f8 |
test = 1
|
|
|
1917f8 |
- self.failUnless(test is 1)
|
|
|
1917f8 |
+ self.assertTrue(test is 1)
|
|
|
1917f8 |
|
|
|
1917f8 |
def testGlyphConsistency(self):
|
|
|
1917f8 |
cm = GlyphConsistency()
|
|
|
1917f8 |
@@ -99,11 +99,11 @@ class Basictests(unittest.TestCase):
|
|
|
1917f8 |
test3 = cm.glyph_round_consistency(testfont,(0x900,0x97f),50)
|
|
|
1917f8 |
|
|
|
1917f8 |
test = (0 <= test1[0][1] <= 10)
|
|
|
1917f8 |
- self.failUnless(test)
|
|
|
1917f8 |
+ self.assertTrue(test)
|
|
|
1917f8 |
test2 = (0 <= test2 <= 10)
|
|
|
1917f8 |
- self.failUnless(test2)
|
|
|
1917f8 |
+ self.assertTrue(test2)
|
|
|
1917f8 |
test3 = (0 <= test3 <= 10)
|
|
|
1917f8 |
- self.failUnless(test3)
|
|
|
1917f8 |
+ self.assertTrue(test3)
|
|
|
1917f8 |
|
|
|
1917f8 |
"""
|
|
|
1917f8 |
unittests for DocCompare not required.
|
|
|
1917f8 |
diff --git a/pycontrib/collab/web-test-collab.py b/pycontrib/collab/web-test-collab.py
|
|
|
1917f8 |
index 47b763f..b19f930 100755
|
|
|
1917f8 |
--- a/pycontrib/collab/web-test-collab.py
|
|
|
1917f8 |
+++ b/pycontrib/collab/web-test-collab.py
|
|
|
1917f8 |
@@ -68,7 +68,7 @@ def OnCollabUpdate(f):
|
|
|
1917f8 |
"end": "null" # this is simply so we dont have to manage keeping the last item with no terminating ,
|
|
|
1917f8 |
},
|
|
|
1917f8 |
sort_keys=True, indent=4, separators=(',', ': '))
|
|
|
1917f8 |
- print js
|
|
|
1917f8 |
+ print(js)
|
|
|
1917f8 |
fi = open(fontJsonOnDisk, 'w')
|
|
|
1917f8 |
fi.write(js)
|
|
|
1917f8 |
|
|
|
1917f8 |
diff --git a/pycontrib/even.py b/pycontrib/even.py
|
|
|
1917f8 |
index 96f9128..4f30fcb 100755
|
|
|
1917f8 |
--- a/pycontrib/even.py
|
|
|
1917f8 |
+++ b/pycontrib/even.py
|
|
|
1917f8 |
@@ -1,4 +1,4 @@
|
|
|
1917f8 |
-#!/usr/bin/python
|
|
|
1917f8 |
+#!/usr/bin/python3
|
|
|
1917f8 |
# -*- coding: utf-8 -*-
|
|
|
1917f8 |
"""
|
|
|
1917f8 |
running even from the fontforge menu
|
|
|
1917f8 |
diff --git a/pycontrib/gdraw/__init__.py b/pycontrib/gdraw/__init__.py
|
|
|
1917f8 |
index d47976c..dde7ea8 100644
|
|
|
1917f8 |
--- a/pycontrib/gdraw/__init__.py
|
|
|
1917f8 |
+++ b/pycontrib/gdraw/__init__.py
|
|
|
1917f8 |
@@ -1,4 +1,4 @@
|
|
|
1917f8 |
-#!/usr/bin/python
|
|
|
1917f8 |
+#!/usr/bin/python3
|
|
|
1917f8 |
# vim:ts=8:sw=4:expandtab:encoding=utf-8
|
|
|
1917f8 |
'''
|
|
|
1917f8 |
Copyright <hashao2@gmail.com> 2009
|
|
|
1917f8 |
@@ -22,7 +22,7 @@ Copyright <hashao2@gmail.com> 2009
|
|
|
1917f8 |
__all__ = ['Timer', 'GtkRunner', 'gtkrunner']
|
|
|
1917f8 |
__version__ = '0.1'
|
|
|
1917f8 |
|
|
|
1917f8 |
-from gdraw import *
|
|
|
1917f8 |
+from .gdraw import *
|
|
|
1917f8 |
|
|
|
1917f8 |
def main():
|
|
|
1917f8 |
pass
|
|
|
1917f8 |
diff --git a/pycontrib/gdraw/gdraw.py b/pycontrib/gdraw/gdraw.py
|
|
|
1917f8 |
index f2d5e50..8b6e693 100755
|
|
|
1917f8 |
--- a/pycontrib/gdraw/gdraw.py
|
|
|
1917f8 |
+++ b/pycontrib/gdraw/gdraw.py
|
|
|
1917f8 |
@@ -1,4 +1,4 @@
|
|
|
1917f8 |
-#!/usr/bin/python
|
|
|
1917f8 |
+#!/usr/bin/python3
|
|
|
1917f8 |
'''ctypes wrapper to Attach the GDraw event handler to the gtk main loop.
|
|
|
1917f8 |
|
|
|
1917f8 |
Copyright <hashao2@gmail.com> 2009
|
|
|
1917f8 |
@@ -67,7 +67,7 @@ def setup_syspath(modpath="modules"):
|
|
|
1917f8 |
|
|
|
1917f8 |
__all__ = ['Timer', 'GtkRunner', 'gtkrunner']
|
|
|
1917f8 |
|
|
|
1917f8 |
-from _gdraw import *
|
|
|
1917f8 |
+from ._gdraw import *
|
|
|
1917f8 |
from ctypes import *
|
|
|
1917f8 |
import types
|
|
|
1917f8 |
|
|
|
1917f8 |
@@ -111,7 +111,7 @@ class Timer:
|
|
|
1917f8 |
|
|
|
1917f8 |
return
|
|
|
1917f8 |
def dodo(*args):
|
|
|
1917f8 |
- print 'aaa'
|
|
|
1917f8 |
+ print('aaa')
|
|
|
1917f8 |
return False
|
|
|
1917f8 |
self.add(1000, dodo)
|
|
|
1917f8 |
|
|
|
1917f8 |
@@ -122,7 +122,7 @@ class Timer:
|
|
|
1917f8 |
|
|
|
1917f8 |
def _event_handler(self, gw, event):
|
|
|
1917f8 |
evt = event.contents
|
|
|
1917f8 |
- print "_event_handler()"
|
|
|
1917f8 |
+ print("_event_handler()")
|
|
|
1917f8 |
if evt.type == et_timer:
|
|
|
1917f8 |
timer = evt.u.timer.timer
|
|
|
1917f8 |
tkey = addressof(timer.contents)
|
|
|
1917f8 |
@@ -147,7 +147,7 @@ class Timer:
|
|
|
1917f8 |
ci.func = CallBackFunc(func)
|
|
|
1917f8 |
ci.data = data
|
|
|
1917f8 |
|
|
|
1917f8 |
- print "timer.add timeout", timeout
|
|
|
1917f8 |
+ print("timer.add timeout", timeout)
|
|
|
1917f8 |
frequency = 1 # Use return value of func() to decide repeat like gtk.
|
|
|
1917f8 |
timer = GDrawRequestTimer(self.win, timeout, timeout, byref(ci))
|
|
|
1917f8 |
|
|
|
1917f8 |
@@ -190,7 +190,7 @@ class GtkRunner:
|
|
|
1917f8 |
|
|
|
1917f8 |
def _do_main(self, *args):
|
|
|
1917f8 |
'''The function called by the gdraw timeout handler.'''
|
|
|
1917f8 |
- print "do_main"
|
|
|
1917f8 |
+ print("do_main")
|
|
|
1917f8 |
while gtk.events_pending():
|
|
|
1917f8 |
gtk.main_iteration(False)
|
|
|
1917f8 |
return True
|
|
|
1917f8 |
@@ -207,15 +207,15 @@ class GtkRunner:
|
|
|
1917f8 |
self.gtk_timer = None
|
|
|
1917f8 |
|
|
|
1917f8 |
def OnDestroyWindow(self, widget, fd ):
|
|
|
1917f8 |
- print fd
|
|
|
1917f8 |
+ print(fd)
|
|
|
1917f8 |
fontforge.removeGtkWindowToMainEventLoopByFD( fd )
|
|
|
1917f8 |
self.stop()
|
|
|
1917f8 |
return True
|
|
|
1917f8 |
|
|
|
1917f8 |
def sniffwindow(self,w):
|
|
|
1917f8 |
'''sniff key presses for a gtk window'''
|
|
|
1917f8 |
- print "sniffwindow w", w
|
|
|
1917f8 |
- print "sniff active font:", fontforge.activeFont()
|
|
|
1917f8 |
+ print("sniffwindow w", w)
|
|
|
1917f8 |
+ print("sniff active font:", fontforge.activeFont())
|
|
|
1917f8 |
w.connect("key-release-event", self._do_main)
|
|
|
1917f8 |
fontforge.addGtkWindowToMainEventLoop(w.window.xid)
|
|
|
1917f8 |
fd = fontforge.getGtkWindowMainEventLoopFD(w.window.xid)
|
|
|
1917f8 |
@@ -223,7 +223,7 @@ class GtkRunner:
|
|
|
1917f8 |
|
|
|
1917f8 |
def sniffwindowid(self,xid):
|
|
|
1917f8 |
'''sniff key presses for a gtk window'''
|
|
|
1917f8 |
- print "sniffwindowid xid", xid
|
|
|
1917f8 |
+ print("sniffwindowid xid", xid)
|
|
|
1917f8 |
#w.connect("key-release-event", self._do_main)
|
|
|
1917f8 |
|
|
|
1917f8 |
def start(self, timeout=GTIMEOUT):
|
|
|
1917f8 |
diff --git a/pycontrib/graphicore.py b/pycontrib/graphicore.py
|
|
|
1917f8 |
index f95e488..229a2b7 100755
|
|
|
1917f8 |
--- a/pycontrib/graphicore.py
|
|
|
1917f8 |
+++ b/pycontrib/graphicore.py
|
|
|
1917f8 |
@@ -1,4 +1,4 @@
|
|
|
1917f8 |
-#!/usr/bin/python
|
|
|
1917f8 |
+#!/usr/bin/python3
|
|
|
1917f8 |
# -*- coding: utf-8 -*-
|
|
|
1917f8 |
"""
|
|
|
1917f8 |
running the fontforge scripts in the graphicore folder on fontforge startup
|
|
|
1917f8 |
@@ -22,4 +22,4 @@ sys.path.append(os.path.dirname(sys.modules[__name__].__file__))
|
|
|
1917f8 |
sys.path.reverse();
|
|
|
1917f8 |
|
|
|
1917f8 |
#load the modules
|
|
|
1917f8 |
-import graphicore.shell
|
|
|
1917f8 |
\ No newline at end of file
|
|
|
1917f8 |
+import graphicore.shell
|
|
|
1917f8 |
diff --git a/pycontrib/graphicore/ipython_view.py b/pycontrib/graphicore/ipython_view.py
|
|
|
1917f8 |
index f39eedb..2b77395 100644
|
|
|
1917f8 |
--- a/pycontrib/graphicore/ipython_view.py
|
|
|
1917f8 |
+++ b/pycontrib/graphicore/ipython_view.py
|
|
|
1917f8 |
@@ -1,4 +1,4 @@
|
|
|
1917f8 |
-#!/usr/bin/python
|
|
|
1917f8 |
+#!/usr/bin/python3
|
|
|
1917f8 |
'''
|
|
|
1917f8 |
Provides IPython console widget.
|
|
|
1917f8 |
|
|
|
1917f8 |
@@ -17,10 +17,11 @@ import re
|
|
|
1917f8 |
import sys
|
|
|
1917f8 |
import os
|
|
|
1917f8 |
import pango
|
|
|
1917f8 |
-from StringIO import StringIO
|
|
|
1917f8 |
-import thread
|
|
|
1917f8 |
+from io import StringIO
|
|
|
1917f8 |
+import _thread
|
|
|
1917f8 |
|
|
|
1917f8 |
import IPython
|
|
|
1917f8 |
+from functools import reduce
|
|
|
1917f8 |
|
|
|
1917f8 |
class IterableIPShell:
|
|
|
1917f8 |
'''
|
|
|
1917f8 |
@@ -118,7 +119,7 @@ class IterableIPShell:
|
|
|
1917f8 |
'''
|
|
|
1917f8 |
This function updates namespace with sys.modules
|
|
|
1917f8 |
'''
|
|
|
1917f8 |
- for k,v in sys.modules.items():
|
|
|
1917f8 |
+ for k,v in list(sys.modules.items()):
|
|
|
1917f8 |
if not '.' in k:
|
|
|
1917f8 |
self.IP.user_ns.update({k:v})
|
|
|
1917f8 |
|
|
|
1917f8 |
@@ -271,11 +272,11 @@ class IterableIPShell:
|
|
|
1917f8 |
@type header: string
|
|
|
1917f8 |
'''
|
|
|
1917f8 |
stat = 0
|
|
|
1917f8 |
- if verbose or debug: print header+cmd
|
|
|
1917f8 |
+ if verbose or debug: print(header+cmd)
|
|
|
1917f8 |
# flush stdout so we don't mangle python's buffering
|
|
|
1917f8 |
if not debug:
|
|
|
1917f8 |
input, output = os.popen4(cmd)
|
|
|
1917f8 |
- print output.read()
|
|
|
1917f8 |
+ print(output.read())
|
|
|
1917f8 |
output.close()
|
|
|
1917f8 |
input.close()
|
|
|
1917f8 |
|
|
|
1917f8 |
diff --git a/pycontrib/graphicore/shell.py b/pycontrib/graphicore/shell.py
|
|
|
1917f8 |
index 5d102f7..32fa584 100755
|
|
|
1917f8 |
--- a/pycontrib/graphicore/shell.py
|
|
|
1917f8 |
+++ b/pycontrib/graphicore/shell.py
|
|
|
1917f8 |
@@ -1,4 +1,4 @@
|
|
|
1917f8 |
-#!/usr/bin/python
|
|
|
1917f8 |
+#!/usr/bin/python3
|
|
|
1917f8 |
# -*- coding: utf-8 -*-
|
|
|
1917f8 |
"""
|
|
|
1917f8 |
FontForge Interactive Python Shell
|
|
|
1917f8 |
@@ -32,7 +32,7 @@ if len(sys.argv) == 0:
|
|
|
1917f8 |
# some versions of IPython need content in sys.argv
|
|
|
1917f8 |
sys.argv.append('')
|
|
|
1917f8 |
|
|
|
1917f8 |
-from ipython_view import *
|
|
|
1917f8 |
+from .ipython_view import *
|
|
|
1917f8 |
import gdraw
|
|
|
1917f8 |
|
|
|
1917f8 |
def runShell(data = None, glyphOrFont = None):
|
|
|
1917f8 |
diff --git a/pycontrib/svg2sfd.py b/pycontrib/svg2sfd.py
|
|
|
1917f8 |
index e1fc0ac..e23cb15 100644
|
|
|
1917f8 |
--- a/pycontrib/svg2sfd.py
|
|
|
1917f8 |
+++ b/pycontrib/svg2sfd.py
|
|
|
1917f8 |
@@ -1,4 +1,4 @@
|
|
|
1917f8 |
-#!/usr/bin/python
|
|
|
1917f8 |
+#!/usr/bin/python3
|
|
|
1917f8 |
#
|
|
|
1917f8 |
# Copyright 2013 Google Inc. All rights reserved.
|
|
|
1917f8 |
#
|
|
|
1917f8 |
@@ -49,7 +49,7 @@ def print_one_cmd(cmd, args):
|
|
|
1917f8 |
result.append('%f' % (scale * args[i]))
|
|
|
1917f8 |
result.append(cmd)
|
|
|
1917f8 |
result.append('0') # TODO: should mark corner points
|
|
|
1917f8 |
- print ' '.join(result)
|
|
|
1917f8 |
+ print(' '.join(result))
|
|
|
1917f8 |
|
|
|
1917f8 |
def apply_rel_xy(xy, args):
|
|
|
1917f8 |
x0, y0 = xy
|
|
|
1917f8 |
@@ -75,7 +75,7 @@ def path_to_sfd(path):
|
|
|
1917f8 |
for i in range(num_args_cmd(cmd)):
|
|
|
1917f8 |
m = fre.match(path)
|
|
|
1917f8 |
if m is None:
|
|
|
1917f8 |
- print 'no float match:', path
|
|
|
1917f8 |
+ print('no float match:', path)
|
|
|
1917f8 |
args.append(float(m.group(1)))
|
|
|
1917f8 |
path = path[m.end():]
|
|
|
1917f8 |
#print cmd, args
|
|
|
1917f8 |
@@ -128,13 +128,13 @@ def conv_svg(fn, char, glyphnum = None):
|
|
|
1917f8 |
if glyphnum == None:
|
|
|
1917f8 |
glyphnum = lastglyphnum + 1
|
|
|
1917f8 |
lastglyphnum = glyphnum
|
|
|
1917f8 |
- print 'StartChar:', os.path.basename(fn)[:-4]
|
|
|
1917f8 |
- print 'Encoding: %d %d %d' % (char, glyphnum, char)
|
|
|
1917f8 |
- print 'Width: %d' % (21 * 40)
|
|
|
1917f8 |
- print 'Flags: W'
|
|
|
1917f8 |
- print 'LayerCount: 2'
|
|
|
1917f8 |
- print 'Fore'
|
|
|
1917f8 |
- print 'SplineSet'
|
|
|
1917f8 |
+ print('StartChar:', os.path.basename(fn)[:-4])
|
|
|
1917f8 |
+ print('Encoding: %d %d %d' % (char, glyphnum, char))
|
|
|
1917f8 |
+ print('Width: %d' % (21 * 40))
|
|
|
1917f8 |
+ print('Flags: W')
|
|
|
1917f8 |
+ print('LayerCount: 2')
|
|
|
1917f8 |
+ print('Fore')
|
|
|
1917f8 |
+ print('SplineSet')
|
|
|
1917f8 |
doc = xml.dom.minidom.parse(fn)
|
|
|
1917f8 |
# TODO: reverse paths if fill color is white-ish (this is more code,
|
|
|
1917f8 |
# and in the meantime, we'll rely on correct path direction in FF)
|
|
|
1917f8 |
@@ -147,16 +147,16 @@ def conv_svg(fn, char, glyphnum = None):
|
|
|
1917f8 |
cy = float(circle.getAttribute('cy'))
|
|
|
1917f8 |
r = float(circle.getAttribute('r'))
|
|
|
1917f8 |
circle_to_sfd(cx, cy, r)
|
|
|
1917f8 |
- print 'EndSplineSet'
|
|
|
1917f8 |
- print 'EndChar'
|
|
|
1917f8 |
+ print('EndSplineSet')
|
|
|
1917f8 |
+ print('EndChar')
|
|
|
1917f8 |
|
|
|
1917f8 |
def print_header():
|
|
|
1917f8 |
global header_printed
|
|
|
1917f8 |
- print '''SplineFontDB: 3.0
|
|
|
1917f8 |
+ print('''SplineFontDB: 3.0
|
|
|
1917f8 |
FontName: %s
|
|
|
1917f8 |
FullName: %s
|
|
|
1917f8 |
-FamilyName: %s''' % (font_name, font_name, font_name)
|
|
|
1917f8 |
- print '''Weight: Medium
|
|
|
1917f8 |
+FamilyName: %s''' % (font_name, font_name, font_name))
|
|
|
1917f8 |
+ print('''Weight: Medium
|
|
|
1917f8 |
Copyright: Copyright (C) 2011 Google Inc.
|
|
|
1917f8 |
Version: 001.000
|
|
|
1917f8 |
UnderlinePosition: -120
|
|
|
1917f8 |
@@ -180,12 +180,12 @@ HheadAOffset: 0
|
|
|
1917f8 |
HheadDescent: 200
|
|
|
1917f8 |
HheadDOffset: 0
|
|
|
1917f8 |
BeginChars: 57600 57600
|
|
|
1917f8 |
-'''
|
|
|
1917f8 |
+''')
|
|
|
1917f8 |
header_printed = True
|
|
|
1917f8 |
|
|
|
1917f8 |
def print_footer():
|
|
|
1917f8 |
- print '''EndChars
|
|
|
1917f8 |
-EndSplineFont'''
|
|
|
1917f8 |
+ print('''EndChars
|
|
|
1917f8 |
+EndSplineFont''')
|
|
|
1917f8 |
|
|
|
1917f8 |
def parse_int(x):
|
|
|
1917f8 |
if x.startswith('0x'):
|
|
|
1917f8 |
@@ -197,7 +197,7 @@ def run_file(fn):
|
|
|
1917f8 |
global char_num
|
|
|
1917f8 |
global font_name
|
|
|
1917f8 |
directory = ''
|
|
|
1917f8 |
- for l in file(fn).xreadlines():
|
|
|
1917f8 |
+ for l in file(fn):
|
|
|
1917f8 |
if l.startswith('#'):
|
|
|
1917f8 |
continue
|
|
|
1917f8 |
s = l.strip().split()
|
|
|
1917f8 |
diff --git a/pycontrib/webcollab.py b/pycontrib/webcollab.py
|
|
|
1917f8 |
index 9ee0f17..4be07ec 100755
|
|
|
1917f8 |
--- a/pycontrib/webcollab.py
|
|
|
1917f8 |
+++ b/pycontrib/webcollab.py
|
|
|
1917f8 |
@@ -1,4 +1,4 @@
|
|
|
1917f8 |
-#!/usr/bin/python
|
|
|
1917f8 |
+#!/usr/bin/python3
|
|
|
1917f8 |
# -*- coding: utf-8 -*-
|
|
|
1917f8 |
"""
|
|
|
1917f8 |
running web collab server hooks
|
|
|
1917f8 |
@@ -44,8 +44,8 @@ def startWebServerInCollabMode(data = None, glyphOrFont = None):
|
|
|
1917f8 |
global child
|
|
|
1917f8 |
global childNodejs
|
|
|
1917f8 |
ensureChildClosed()
|
|
|
1917f8 |
- print("FONTFORGE:" + FONTFORGE)
|
|
|
1917f8 |
- print("script path:" + collabpath + "web-test-collab.py")
|
|
|
1917f8 |
+ print(("FONTFORGE:" + FONTFORGE))
|
|
|
1917f8 |
+ print(("script path:" + collabpath + "web-test-collab.py"))
|
|
|
1917f8 |
child = subprocess.Popen( [ FONTFORGE, "-forceuihidden", "-script", collabpath + "web-test-collab.py" ] )
|
|
|
1917f8 |
#
|
|
|
1917f8 |
# start the nodejs server
|
|
|
1917f8 |
--
|
|
|
1917f8 |
2.9.3
|
|
|
1917f8 |
|