import stat


def rwxtype(mode):
  """ Returns l/d/-/? for use in "rwx" style strings. """
  if stat.S_ISLNK(mode):
    return "l"
  elif stat.S_ISDIR(mode):
    return "d"
  elif stat.S_ISREG(mode):
    return "-"
  else:
    return "?"