textTools: safeEval = ast.literal_eval

https://github.com/fonttools/fonttools/pull/1139#pullrequestreview-86720679
This commit is contained in:
Cosimo Lupo 2018-01-04 19:41:52 +00:00
parent 4a20899cb4
commit 2b13c47d3e

View File

@ -7,15 +7,15 @@ import ast
import string
def safeEval(data):
"""A (kindof) safe replacement for eval."""
return ast.literal_eval(data)
# alias kept for backward compatibility
safeEval = ast.literal_eval
def readHex(content):
"""Convert a list of hex strings to binary data."""
return deHexStr(strjoin(chunk for chunk in content if isinstance(chunk, basestring)))
def deHexStr(hexdata):
"""Convert a hex string to binary data."""
hexdata = strjoin(hexdata.split())