etree/plistlib/glifLib: using (default) single quotes in XML_DECLARATION
https://github.com/fonttools/fonttools/pull/1335#issuecomment-431118568
This commit is contained in:
parent
6db88d7cb7
commit
8081bf57fa
@ -14,10 +14,8 @@ iterwalk.
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
from fontTools.misc.py23 import basestring, unicode, tounicode, open
|
||||
|
||||
# we use a custom XML declaration for backward compatibility with older
|
||||
# ufoLib versions which would write it using double quotes.
|
||||
# https://github.com/unified-font-object/ufoLib/issues/158
|
||||
XML_DECLARATION = """<?xml version="1.0" encoding="%s"?>"""
|
||||
|
||||
XML_DECLARATION = """<?xml version='1.0' encoding='%s'?>"""
|
||||
|
||||
__all__ = [
|
||||
# public symbols
|
||||
|
@ -41,10 +41,7 @@ if PY3:
|
||||
else:
|
||||
USE_BUILTIN_TYPES = False
|
||||
|
||||
# we use a custom XML declaration for backward compatibility with older
|
||||
# ufoLib versions which would write it using double quotes.
|
||||
# https://github.com/unified-font-object/ufoLib/issues/158
|
||||
XML_DECLARATION = b"""<?xml version="1.0" encoding="UTF-8"?>"""
|
||||
XML_DECLARATION = b"""<?xml version='1.0' encoding='UTF-8'?>"""
|
||||
|
||||
PLIST_DOCTYPE = (
|
||||
b'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" '
|
||||
|
@ -575,9 +575,6 @@ def readGlyphFromString(aString, glyphObject=None, pointPen=None, formatVersions
|
||||
_readGlyphFromTree(tree, glyphObject, pointPen, formatVersions=formatVersions, validate=validate)
|
||||
|
||||
|
||||
_XML_DECLARATION = plistlib.XML_DECLARATION + b"\n"
|
||||
|
||||
|
||||
def _writeGlyphToBytes(
|
||||
glyphName, glyphObject=None, drawPointsFunc=None, writer=None,
|
||||
formatVersion=2, validate=True):
|
||||
@ -621,8 +618,8 @@ def _writeGlyphToBytes(
|
||||
if getattr(glyphObject, "lib", None):
|
||||
_writeLib(glyphObject, root, validate)
|
||||
# return the text
|
||||
data = _XML_DECLARATION + etree.tostring(
|
||||
root, encoding="utf-8", xml_declaration=False, pretty_print=True
|
||||
data = etree.tostring(
|
||||
root, encoding="UTF-8", xml_declaration=True, pretty_print=True
|
||||
)
|
||||
return data
|
||||
|
||||
|
@ -7,8 +7,8 @@ from io import open
|
||||
from .testSupport import getDemoFontGlyphSetPath
|
||||
from fontTools.ufoLib.glifLib import (
|
||||
GlyphSet, glyphNameToFileName, readGlyphFromString, writeGlyphToString,
|
||||
_XML_DECLARATION,
|
||||
)
|
||||
from fontTools.misc.etree import XML_DECLARATION
|
||||
|
||||
GLYPHSETDIR = getDemoFontGlyphSetPath()
|
||||
|
||||
@ -161,4 +161,4 @@ class ReadWriteFuncTest(unittest.TestCase):
|
||||
|
||||
def testXmlDeclaration(self):
|
||||
s = writeGlyphToString("a", _Glyph())
|
||||
self.assertTrue(s.startswith(_XML_DECLARATION.decode("utf-8")))
|
||||
self.assertTrue(s.startswith(XML_DECLARATION % "UTF-8"))
|
||||
|
Loading…
x
Reference in New Issue
Block a user