mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 20:22:45 +01:00
Added orderAlphabetically.
This commit is contained in:
parent
d62a96679f
commit
aad768c188
@ -111,8 +111,9 @@ def close(registry, filename, annotated=True, helpOnceOnly=False):
|
|||||||
def isValidRegistryName(name):
|
def isValidRegistryName(name):
|
||||||
# Now we can have . and : in names. I'm still gonna call shenanigans on
|
# Now we can have . and : in names. I'm still gonna call shenanigans on
|
||||||
# anyone who tries to have spaces (though technically I can't see any
|
# anyone who tries to have spaces (though technically I can't see any
|
||||||
# reason why it wouldn't work).
|
# reason why it wouldn't work). We also reserve all names starting with
|
||||||
return len(name.split()) == 1
|
# underscores for internal use.
|
||||||
|
return len(name.split()) == 1 and not name.startswith('_')
|
||||||
|
|
||||||
def escape(name):
|
def escape(name):
|
||||||
name = name.replace('\\', '\\\\')
|
name = name.replace('\\', '\\\\')
|
||||||
@ -135,12 +136,13 @@ def join(names):
|
|||||||
|
|
||||||
class Group(object):
|
class Group(object):
|
||||||
"""A group; it doesn't hold a value unless handled by a subclass."""
|
"""A group; it doesn't hold a value unless handled by a subclass."""
|
||||||
def __init__(self, supplyDefault=False):
|
def __init__(self, supplyDefault=False, orderAlphabetically=False):
|
||||||
self._name = 'unset'
|
self._name = 'unset'
|
||||||
self._added = []
|
self._added = []
|
||||||
self._children = utils.InsensitivePreservingDict()
|
self._children = utils.InsensitivePreservingDict()
|
||||||
self._lastModified = 0
|
self._lastModified = 0
|
||||||
self._supplyDefault = supplyDefault
|
self._supplyDefault = supplyDefault
|
||||||
|
self._orderAlphabetically = orderAlphabetically
|
||||||
OriginalClass = self.__class__
|
OriginalClass = self.__class__
|
||||||
class X(OriginalClass):
|
class X(OriginalClass):
|
||||||
"""This class exists to differentiate those values that have
|
"""This class exists to differentiate those values that have
|
||||||
@ -240,6 +242,8 @@ class Group(object):
|
|||||||
|
|
||||||
def getValues(self, getChildren=False, fullNames=True):
|
def getValues(self, getChildren=False, fullNames=True):
|
||||||
L = []
|
L = []
|
||||||
|
if self._orderAlphabetically:
|
||||||
|
self._added.sort()
|
||||||
for name in self._added:
|
for name in self._added:
|
||||||
node = self._children[name]
|
node = self._children[name]
|
||||||
if hasattr(node, 'value') or hasattr(node, 'help'):
|
if hasattr(node, 'value') or hasattr(node, 'help'):
|
||||||
|
Loading…
Reference in New Issue
Block a user