Skip to content

Commit

Permalink
Preserve order of types for documentation purposes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Feb 22, 2017
1 parent 8861d41 commit 09dd63e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions ZConfig/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import ZConfig

from abc import abstractmethod
from collections import OrderedDict
from functools import total_ordering

from ZConfig._compat import AbstractBaseClass
Expand Down Expand Up @@ -137,7 +138,7 @@ def prepare_raw_defaults(self):
assert self.name == "+"
if self._rawdefaults is None:
self._rawdefaults = self._default
self._default = {}
self._default = OrderedDict()


class KeyInfo(BaseKeyInfo):
Expand All @@ -148,7 +149,7 @@ def __init__(self, name, datatype, minOccurs, handler, attribute):
BaseKeyInfo.__init__(self, name, datatype, minOccurs, 1,
handler, attribute)
if self.name == "+":
self._default = {}
self._default = OrderedDict()

def add_valueinfo(self, vi, key):
if self.name == "+":
Expand Down Expand Up @@ -184,7 +185,7 @@ def __init__(self, name, datatype, minOccurs, maxOccurs, handler,
BaseKeyInfo.__init__(self, name, datatype, minOccurs, maxOccurs,
handler, attribute)
if self.name == "+":
self._default = {}
self._default = OrderedDict()
else:
self._default = []

Expand Down Expand Up @@ -275,12 +276,12 @@ class AbstractType(object):
__slots__ = '_subtypes', 'name', 'description'

def __init__(self, name):
self._subtypes = {}
self._subtypes = OrderedDict()
self.name = name
self.description = None

def __iter__(self):
return iter(sorted(self._subtypes.items()))
return iter(self._subtypes.items())

def addsubtype(self, type):
self._subtypes[type.name] = type
Expand Down Expand Up @@ -319,8 +320,8 @@ def __init__(self, name, keytype, valuetype, datatype, registry, types):
self.example = None
self.registry = registry
self._children = [] # [(key, info), ...]
self._attrmap = {} # {attribute: info, ...}
self._keymap = {} # {key: info, ...}
self._attrmap = OrderedDict() # {attribute: info, ...}
self._keymap = OrderedDict() # {key: info, ...}
self._types = types

def gettype(self, name):
Expand Down Expand Up @@ -378,7 +379,7 @@ def getinfo(self, key):
raise ZConfig.ConfigurationError("no key matching " + repr(key))

def getrequiredtypes(self):
d = {}
d = OrderedDict()
if self.name:
d[self.name] = 1
stack = [self]
Expand Down Expand Up @@ -443,7 +444,7 @@ def __init__(self, keytype, valuetype, datatype, handler, url,
registry):
SectionType.__init__(self, None, keytype, valuetype, datatype,
registry, {})
self._components = {}
self._components = OrderedDict()
self.handler = handler
self.url = url

Expand Down

0 comments on commit 09dd63e

Please sign in to comment.