(path, user=None, group=None)
Change owner user and group of the given path.

    user and group can be the uid/gid or the user/group names, and in that case,
    they are converted to their respective uid/gid.
Change owner user and group of the given path.
Change owner user and group of the given path .
def chown(path, user=None, group=None):
    """Change owner user and group of the given path.

    user and group can be the uid/gid or the user/group names, and in that case,
    they are converted to their respective uid/gid.
    """
    sys.audit('shutil.chown', path, user, group)

    if user is None and group is None:
        raise ValueError("user and/or group must be set")

    _user = user
    _group = group

    # -1 means don't change it
    if user is None:
        _user = -1
    # user can either be an int (the uid) or a string (the system username)
    elif isinstance(user, str):
        _user = _get_uid(user)
        if _user is None:
            raise LookupError("no such user: {!r}".format(user))

    if group is None:
        _group = -1
    elif not isinstance(group, int):
        _group = _get_gid(group)
        if _group is None:
            raise LookupError("no such group: {!r}".format(group))

    os.chown(path, _user, _group)
def chown ( path , user = None , group = None ) : sys . audit ( 'shutil.chown' , path , user , group ) if user is None and group is None : raise ValueError ( "user and/or group must be set" ) _user = user _group = group # -1 means don't change it if user is None : _user = - 1 # user can either be an int (the uid) or a string (the system username) elif isinstance ( user , str ) : _user = _get_uid ( user ) if _user is None : raise LookupError ( "no such user: {!r}" . format ( user ) ) if group is None : _group = - 1 elif not isinstance ( group , int ) : _group = _get_gid ( group ) if _group is None : raise LookupError ( "no such group: {!r}" . format ( group ) ) os . chown ( path , _user , _group )