MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / chown

Function chown

tools/python-3.11.9-amd64/Lib/shutil.py:1394–1424  ·  view source on GitHub ↗

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.

(path, user=None, group=None)

Source from the content-addressed store, hash-verified

1392
1393
1394def chown(path, user=None, group=None):
1395 """Change owner user and group of the given path.
1396
1397 user and group can be the uid/gid or the user/group names, and in that case,
1398 they are converted to their respective uid/gid.
1399 """
1400 sys.audit('shutil.chown', path, user, group)
1401
1402 if user is None and group is None:
1403 raise ValueError("user and/or group must be set")
1404
1405 _user = user
1406 _group = group
1407
1408 # -1 means don't change it
1409 if user is None:
1410 _user = -1
1411 # user can either be an int (the uid) or a string (the system username)
1412 elif isinstance(user, str):
1413 _user = _get_uid(user)
1414 if _user is None:
1415 raise LookupError("no such user: {!r}".format(user))
1416
1417 if group is None:
1418 _group = -1
1419 elif not isinstance(group, int):
1420 _group = _get_gid(group)
1421 if _group is None:
1422 raise LookupError("no such group: {!r}".format(group))
1423
1424 os.chown(path, _user, _group)
1425
1426def get_terminal_size(fallback=(80, 24)):
1427 """Get the size of the terminal window.

Callers

nothing calls this directly

Calls 4

chownMethod · 0.80
_get_uidFunction · 0.70
_get_gidFunction · 0.70
formatMethod · 0.45

Tested by

no test coverage detected