Skip to content

Commit

Permalink
Py3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jenskutilek committed Jan 10, 2018
1 parent 2690389 commit efc1762
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Extensions/UFO Cleaner.roboFontExt/lib/UFOCleaner.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import vanilla
from string import split
from sys import getsizeof
from defconAppKit.windows.baseWindow import BaseWindowController
from lib.scripting.codeEditor import CodeEditor
from robofab.plistlib import writePlistToString
try:
from plistlib import writePlistToString
except ImportError:
from plistlib import dumps as writePlistToString
from knownKeys import known_keys


Expand Down Expand Up @@ -82,14 +84,14 @@ def _collect_keys(self):
if not k in self._seen_keys:
self._libkeys.append({
"Delete": False,
"Description": self._known_keys.get(k, "(%s)" % split(k, ".")[-1]),
"Description": self._known_keys.get(k, "(%s)" % k.split(".")[-1]),
"Size": "? kB",
"Key": k,
"Location": "Font",
})
self._seen_keys.append(k)
self._key_contents[k] = ""
self._key_contents[k] += writePlistToString(self._font.lib[k])[173:-9]
self._key_contents[k] += writePlistToString(self._font.lib[k])[173:-9].decode("utf-8")
self._key_sizes[k] = len(self._key_contents[k])

# Glyph libs
Expand All @@ -98,14 +100,14 @@ def _collect_keys(self):
if not k in self._seen_keys:
self._libkeys.append({
"Delete": False,
"Description": self._known_keys.get(k, "(%s)" % split(k, ".")[-1]),
"Description": self._known_keys.get(k, "(%s)" % k.split(".")[-1]),
"Size": "? kB",
"Key": k,
"Location": "Glyph",
})
self._seen_keys.append(k)
self._key_contents[k] = ""
self._key_contents[k] += writePlistToString(g.lib[k])[173:-9]
self._key_contents[k] += writePlistToString(g.lib[k])[173:-9].decode("utf-8")
self._key_sizes[k] = len(self._key_contents[k])

# Collect key sizes
Expand Down Expand Up @@ -167,4 +169,4 @@ def windowCloseCallback(self, sender):
# self.s.close()
super(UFOCleaner, self).windowCloseCallback(sender)

OpenWindow(UFOCleaner)
OpenWindow(UFOCleaner)

0 comments on commit efc1762

Please sign in to comment.