def expanduser(path):
if hdfs_fs.default_is_local():<EOL><INDENT>return os.path.expanduser(path)<EOL><DEDENT>m = re.match(r'<STR_LIT>', path)<EOL>if m is None:<EOL><INDENT>return path<EOL><DEDENT>user = m.groups()[<NUM_LIT:0>] or common.DEFAULT_USER<EOL>return '<STR_LIT>' % (user, path[m.end(<NUM_LIT:1>):])<EOL>
Replace initial ``~`` or ``~user`` with the user's home directory.

**NOTE:** if the default file system is HDFS, the ``~user`` form is
expanded regardless of the user's existence.