Merge pull request #11 from brawer/bug-10
Make the order of location elements deterministic
This commit is contained in:
commit
87648c31d0
@ -1,6 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from __future__ import print_function, division, absolute_import
|
from __future__ import print_function, division, absolute_import
|
||||||
|
import collections
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
@ -255,7 +256,7 @@ class BaseDocWriter(object):
|
|||||||
self.rules = []
|
self.rules = []
|
||||||
|
|
||||||
def newDefaultLocation(self):
|
def newDefaultLocation(self):
|
||||||
loc = {}
|
loc = collections.OrderedDict()
|
||||||
for axisDescriptor in self.axes:
|
for axisDescriptor in self.axes:
|
||||||
loc[axisDescriptor.name] = axisDescriptor.default
|
loc[axisDescriptor.name] = axisDescriptor.default
|
||||||
return loc
|
return loc
|
||||||
@ -291,7 +292,9 @@ class BaseDocWriter(object):
|
|||||||
if name is not None:
|
if name is not None:
|
||||||
locElement.attrib['name'] = name
|
locElement.attrib['name'] = name
|
||||||
defaultLoc = self.newDefaultLocation()
|
defaultLoc = self.newDefaultLocation()
|
||||||
validatedLocation = {}
|
# Without OrderedDict, output XML would be non-deterministic.
|
||||||
|
# https://github.com/LettError/designSpaceDocument/issues/10
|
||||||
|
validatedLocation = collections.OrderedDict()
|
||||||
for axisName, axisValue in defaultLoc.items():
|
for axisName, axisValue in defaultLoc.items():
|
||||||
# update the location dict with missing default axis values
|
# update the location dict with missing default axis values
|
||||||
validatedLocation[axisName] = locationObject.get(axisName, axisValue)
|
validatedLocation[axisName] = locationObject.get(axisName, axisValue)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user