def _expand_variables(self, config, hostname):
if "<STR_LIT>" in config:<EOL><INDENT>config["<STR_LIT>"] = config["<STR_LIT>"].replace("<STR_LIT>", hostname)<EOL><DEDENT>else:<EOL><INDENT>config["<STR_LIT>"] = hostname<EOL><DEDENT>if "<STR_LIT:port>" in config:<EOL><INDENT>port = config["<STR_LIT:port>"]<EOL><DEDENT>else:<EOL><INDENT>port = SSH_PORT<EOL><DEDENT>user = os.getenv("<STR_LIT>")<EOL>if "<STR_LIT:user>" in config:<EOL><INDENT>remoteuser = config["<STR_LIT:user>"]<EOL><DEDENT>else:<EOL><INDENT>remoteuser = user<EOL><DEDENT>host = socket.gethostname().split("<STR_LIT:.>")[<NUM_LIT:0>]<EOL>fqdn = LazyFqdn(config, host)<EOL>homedir = os.path.expanduser("<STR_LIT>")<EOL>replacements = {<EOL>"<STR_LIT>": [<EOL>("<STR_LIT>", config["<STR_LIT>"]),<EOL>("<STR_LIT>", fqdn),<EOL>("<STR_LIT>", host),<EOL>("<STR_LIT>", hostname),<EOL>("<STR_LIT>", port),<EOL>("<STR_LIT>", remoteuser),<EOL>("<STR_LIT>", user),<EOL>],<EOL>"<STR_LIT>": [<EOL>("<STR_LIT>", homedir),<EOL>("<STR_LIT>", homedir),<EOL>("<STR_LIT>", config["<STR_LIT>"]),<EOL>("<STR_LIT>", fqdn),<EOL>("<STR_LIT>", user),<EOL>("<STR_LIT>", remoteuser),<EOL>],<EOL>"<STR_LIT>": [<EOL>("<STR_LIT>", homedir),<EOL>("<STR_LIT>", config["<STR_LIT>"]),<EOL>("<STR_LIT>", port),<EOL>("<STR_LIT>", remoteuser),<EOL>],<EOL>}<EOL>for k in config:<EOL><INDENT>if config[k] is None:<EOL><INDENT>continue<EOL><DEDENT>if k in replacements:<EOL><INDENT>for find, replace in replacements[k]:<EOL><INDENT>if isinstance(config[k], list):<EOL><INDENT>for item in range(len(config[k])):<EOL><INDENT>if find in config[k][item]:<EOL><INDENT>config[k][item] = config[k][item].replace(<EOL>find, str(replace)<EOL>)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if find in config[k]:<EOL><INDENT>config[k] = config[k].replace(find, str(replace))<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>return config<EOL>
Return a dict of config options with expanded substitutions
for a given hostname.

Please refer to man ``ssh_config`` for the parameters that
are replaced.

:param dict config: the config for the hostname
:param str hostname: the hostname that the config belongs to