diff --git a/podman-compose.py b/podman-compose.py index 019e00a..4dbd5e5 100755 --- a/podman-compose.py +++ b/podman-compose.py @@ -25,10 +25,22 @@ PY3 = sys.version_info[0] == 3 if PY3: basestring = str +# helper functions + is_str = lambda s: isinstance(s, basestring) is_dict = lambda d: isinstance(d, dict) is_list = lambda l: not is_str(l) and not is_dict(l) and hasattr(l, "__iter__") +def try_int(i, fallback=None): + try: + return int(i) + except ValueError: + pass + except TypeError: + pass + return fallback + + # docker and docker-compose support subset of bash variable substitution # https://docs.docker.com/compose/compose-file/#variable-substitution # https://docs.docker.com/compose/env-file/ @@ -79,17 +91,6 @@ def rec_subs(value, dicts): value = [rec_subs(i, dicts) for i in value] return value - -# helper functions -def try_int(i, fallback=None): - try: - return int(i) - except ValueError: - pass - except TypeError: - pass - return fallback - def norm_as_list(src): """ given a dictionary {key1:value1, key2: None} or list