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 = socket.getfqdn()<EOL>homedir = os.path.expanduser('<STR_LIT>')<EOL>replacements = {'<STR_LIT>' :<EOL>[<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>[<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>}<EOL>for k in config:<EOL><INDENT>if k in replacements:<EOL><INDENT>for find, replace in replacements[k]:<EOL><INDENT>config[k] = config[k].replace(find, str(replace))<EOL><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(5) for the parameters that
are replaced.

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