code: def expanduser(path):
      
      if hdfs_fs.default_is_local():
          return os.path.expanduser(path)
      m = re.match(r'^~([^/]*)', path)
      if m is None:
          return path
      user = m.groups()[0] or common.DEFAULT_USER
      return '/user/%s%s' % (user, path[m.end(1):])
docs: 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.