mirror of
https://github.com/containers/podman-compose.git
synced 2025-04-02 20:26:16 +02:00
handle none and integers
This commit is contained in:
parent
021f0565e8
commit
4fc8f5d702
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import sys
|
||||||
import os
|
import os
|
||||||
import argparse
|
import argparse
|
||||||
import subprocess
|
import subprocess
|
||||||
@ -20,6 +21,10 @@ import fnmatch
|
|||||||
import json
|
import json
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
PY3 = sys.version_info[0] == 3
|
||||||
|
if PY3:
|
||||||
|
basestring = str
|
||||||
|
|
||||||
# docker and docker-compose support subset of bash variable substitution
|
# docker and docker-compose support subset of bash variable substitution
|
||||||
# https://docs.docker.com/compose/compose-file/#variable-substitution
|
# https://docs.docker.com/compose/compose-file/#variable-substitution
|
||||||
# https://docs.docker.com/compose/env-file/
|
# https://docs.docker.com/compose/env-file/
|
||||||
@ -53,7 +58,7 @@ def rec_subs(value, dicts):
|
|||||||
value = dict([(k, rec_subs(v, dicts)) for k, v in value.items()])
|
value = dict([(k, rec_subs(v, dicts)) for k, v in value.items()])
|
||||||
elif hasattr(value, "__iter__"):
|
elif hasattr(value, "__iter__"):
|
||||||
value = [rec_subs(i, dicts) for i in value]
|
value = [rec_subs(i, dicts) for i in value]
|
||||||
else:
|
elif isinstance(value, basestring):
|
||||||
value = var_re.sub(lambda m: dicts_get(dicts, m.group(1).strip('{}')), value)
|
value = var_re.sub(lambda m: dicts_get(dicts, m.group(1).strip('{}')), value)
|
||||||
sub_def = lambda m: dicts_get(dicts, m.group(1), m.group(3), m.group(2) == ':')
|
sub_def = lambda m: dicts_get(dicts, m.group(1), m.group(3), m.group(2) == ':')
|
||||||
value = var_def_re.sub(sub_def, value)
|
value = var_def_re.sub(sub_def, value)
|
||||||
|
Loading…
Reference in New Issue
Block a user