def expand_system_vars(data):
def _expanded(value):<EOL><INDENT>if isinstance(value, str):<EOL><INDENT>value = expandvars(value)<EOL>value = expanduser(value)<EOL>return scoped_format(value, system=system)<EOL><DEDENT>elif isinstance(value, (list, tuple, set)):<EOL><INDENT>return [_expanded(x) for x in value]<EOL><DEDENT>elif isinstance(value, dict):<EOL><INDENT>return dict((k, _expanded(v)) for k, v in value.items())<EOL><DEDENT>else:<EOL><INDENT>return value<EOL><DEDENT><DEDENT>return _expanded(data)<EOL>
Expands any strings within `data` such as '{system.user}'.