Add default layerOrder to writeLayerContents

This commit is contained in:
Lasse Fister 2014-12-08 15:43:19 +01:00
parent 24676b3ebb
commit e875cfe3ec

View File

@ -991,12 +991,15 @@ class UFOWriter(object):
""" """
if self.formatVersion < 3: if self.formatVersion < 3:
return return
if layerOrder is not None:
newOrder = [] newOrder = []
for layerName in layerOrder: for layerName in layerOrder:
if layerName is None: if layerName is None:
layerName = DEFAULT_LAYER_NAME layerName = DEFAULT_LAYER_NAME
newOrder.append(layerName) newOrder.append(layerName)
layerOrder = newOrder layerOrder = newOrder
else:
layerOrder = self.layerContents.keys()
if set(layerOrder) != set(self.layerContents.keys()): if set(layerOrder) != set(self.layerContents.keys()):
raise UFOLibError("The layer order contents does not match the glyph sets that have been created.") raise UFOLibError("The layer order contents does not match the glyph sets that have been created.")
layerContents = [(layerName, self.layerContents[layerName]) for layerName in layerOrder] layerContents = [(layerName, self.layerContents[layerName]) for layerName in layerOrder]