# Path: paramiko/py3compat.py
# PY2 = sys.version_info[0] < 3
#         MAXSIZE = int((1 << 31) - 1)  # NOQA
#         MAXSIZE = int((1 << 63) - 1)  # NOQA
#     MAXSIZE = sys.maxsize  # NOQA
#     def bytestring(s):  # NOQA
#     def byte_mask(c, mask):
#     def b(s, encoding="utf8"):  # NOQA
#     def u(s, encoding="utf8"):  # NOQA
#     def b2s(s):
#     def is_callable(c):  # NOQA
#     def get_next(c):  # NOQA
#     def next(c):
#         def __len__(self):
#     def strftime(format, t):
#     def byte_ord(c):
#     def byte_chr(c):
#     def byte_mask(c, mask):
#     def b(s, encoding="utf8"):
#     def u(s, encoding="utf8"):
#     def b2s(s):
#     def is_callable(c):
#     def get_next(c):
#     class X(object):
#     class long(int):
# 
# Path: paramiko/ssh_exception.py
# class CouldNotCanonicalize(SSHException):
#     """
#     Raised when hostname canonicalization fails & fallback is disabled.
# 
#     .. versionadded:: 2.7
#     """
# 
#     pass
# 
# class ConfigParseError(SSHException):
#     """
#     A fatal error was encountered trying to parse SSH config data.
# 
#     Typically this means a config file violated the ``ssh_config``
#     specification in a manner that requires exiting immediately, such as not
#     matching ``key = value`` syntax or misusing certain ``Match`` keywords.
# 
#     .. versionadded:: 2.7
#     """
# 
#     pass


import fnmatch
import getpass
import os
import re
import shlex
import socket
    import invoke
from functools import partial
from .py3compat import StringIO
from .ssh_exception import CouldNotCanonicalize, ConfigParseError
        return self.TOKENS_BY_CONFIG_KEY.get(key, [])

    def _expand_variables(self, config, target_hostname):
        """
        Return a dict of config options with expanded substitutions
        for a given original & current target hostname.

        Please refer to :doc:`/api/config` for details.

        :param dict config: the currently parsed config
        :param str hostname: the hostname whose config is being looked up
        """
        for k in config:
            if config[k] is None:
                continue
            tokenizer = partial(self._tokenize, config, target_hostname, k)
            if isinstance(config[k], list):
                for i, value in enumerate(config[k]):
                    config[k][i] = tokenizer(value)
            else:
                config[k] = tokenizer(config[k])
        return config

    def _get_hosts(self, host):
        """
        Return a list of host_names from host value.
        """
        try:
            return shlex.split(host)
        except ValueError:

# Path: paramiko/py3compat.py
# PY2 = sys.version_info[0] < 3
#         MAXSIZE = int((1 << 31) - 1)  # NOQA
#         MAXSIZE = int((1 << 63) - 1)  # NOQA
#     MAXSIZE = sys.maxsize  # NOQA
#     def bytestring(s):  # NOQA
#     def byte_mask(c, mask):
#     def b(s, encoding="utf8"):  # NOQA
#     def u(s, encoding="utf8"):  # NOQA
#     def b2s(s):
#     def is_callable(c):  # NOQA
#     def get_next(c):  # NOQA
#     def next(c):
#         def __len__(self):
#     def strftime(format, t):
#     def byte_ord(c):
#     def byte_chr(c):
#     def byte_mask(c, mask):
#     def b(s, encoding="utf8"):
#     def u(s, encoding="utf8"):
#     def b2s(s):
#     def is_callable(c):
#     def get_next(c):
#     class X(object):
#     class long(int):
# 
# Path: paramiko/ssh_exception.py
# class CouldNotCanonicalize(SSHException):
#     """
#     Raised when hostname canonicalization fails & fallback is disabled.
# 
#     .. versionadded:: 2.7
#     """
# 
#     pass
# 
# class ConfigParseError(SSHException):
#     """
#     A fatal error was encountered trying to parse SSH config data.
# 
#     Typically this means a config file violated the ``ssh_config``
#     specification in a manner that requires exiting immediately, such as not
#     matching ``key = value`` syntax or misusing certain ``Match`` keywords.
# 
#     .. versionadded:: 2.7
#     """
# 
#     pass


# Path: paramiko/config.py
import fnmatch
import getpass
import os
import re
import shlex
import socket
    import invoke
from functools import partial
from .py3compat import StringIO
from .ssh_exception import CouldNotCanonicalize, ConfigParseError

        return self.TOKENS_BY_CONFIG_KEY.get(key, [])

    def _expand_variables(self, config, target_hostname):
        """
        Return a dict of config options with expanded substitutions
        for a given original & current target hostname.

        Please refer to :doc:`/api/config` for details.

        :param dict config: the currently parsed config
        :param str hostname: the hostname whose config is being looked up
        """
        for k in config:
            if config[k] is None:
                continue
            tokenizer = partial(self._tokenize, config, target_hostname, k)
            if isinstance(config[k], list):
                for i, value in enumerate(config[k]):
                    config[k][i] = tokenizer(value)
            else:
                config[k] = tokenizer(config[k])
        return config

    def _get_hosts(self, host):
        """
        Return a list of host_names from host value.
        """
        try:
            return shlex.split(host)
        except ValueError:

            raise ConfigParseError("Unparsable host {}".format(host))