docs: def uid_gid(user, group, fd=None, path=None):
      '''Get uid and gid from either uid/gid, user name/group name, or from the
         environment of the calling process, or optionally from an fd, or
         optionally from a path'''
      type_msg = u'{0} must be a string or integer, not: {1}'
      nosuch_msg = u'no such {0}: {1}'
      if fd is not None and path is not None:
          raise ValueError(u'received path and fd arguments, need one or'\
                           u' neither, not both.')
  
      # -1 is don't change for chown/fchown
      user = -1 if user is None else user
      group = -1 if group is None else group
      try:
          user = int(user)
      except (TypeError, ValueError):
          try:
              user = pwd.getpwnam(user).pw_uid
          except TypeError:
              raise TypeError(type_msg.format(u'user', user.__class__.__name__))
          except KeyError:
              raise FSQEnvError(errno.EINVAL, nosuch_msg.format(u'user', user))
      except TypeError:
          raise TypeError(type_msg.format(u'group', group.__class__.__name__))
      try:
          group = int(group)
      except ValueError:
          try:
              group = grp.getgrnam(group).gr_gid
          except TypeError:
              raise TypeError(type_msg.format(u'group',
                              group.__class__.__name__))
          except KeyError:
              raise FSQEnvError(errno.EINVAL, nosuch_msg.format(u'group',
                                group))
      except TypeError:
          raise TypeError(type_msg.format(u'group', group.__class__.__name__))
  
      return user, group