Sort link names by len

pull/1/head
Christophe Mehay 8 years ago
parent bd65d60d51
commit 7518e360be

@ -4,5 +4,3 @@ from __future__ import unicode_literals
from .constants import *
from .docker_links import DockerLinks
from .entrypoint import Entrypoint
__version__ = '0.1.1'

@ -1 +1,3 @@
from __future__ import unicode_literals
ENTRYPOINT_FILE = 'entrypoint-config.yml'

@ -61,7 +61,7 @@ class DockerLinks(object):
}
def _sort_names(self):
"Sort names by len and put hexa at the end of list"
def test_split(name):
"Select key found in env"
return bool([key for key in os.environ
@ -71,7 +71,7 @@ class DockerLinks(object):
names = [name for name in item["names"] if test_split(name)]
hexa = [name for name in item["names"] if not test_split(name)]
names.sort()
names.sort(key=len)
hexa.sort()
item["names"] = names + hexa

@ -99,6 +99,7 @@ def test_containers():
# Test sorted names
int(ctn.names[-1], base=16)
assert len(ctn.names[0]) <= len(ctn.names[1])
def test_templates():

Loading…
Cancel
Save