Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../usr/lib64/python3....
File: stat.py
"""Constants/functions for interpreting results of os.stat() and os.lstat().
[0] Fix | Delete
[1] Fix | Delete
Suggested usage: from stat import *
[2] Fix | Delete
"""
[3] Fix | Delete
[4] Fix | Delete
# Indices for stat struct members in the tuple returned by os.stat()
[5] Fix | Delete
[6] Fix | Delete
ST_MODE = 0
[7] Fix | Delete
ST_INO = 1
[8] Fix | Delete
ST_DEV = 2
[9] Fix | Delete
ST_NLINK = 3
[10] Fix | Delete
ST_UID = 4
[11] Fix | Delete
ST_GID = 5
[12] Fix | Delete
ST_SIZE = 6
[13] Fix | Delete
ST_ATIME = 7
[14] Fix | Delete
ST_MTIME = 8
[15] Fix | Delete
ST_CTIME = 9
[16] Fix | Delete
[17] Fix | Delete
# Extract bits from the mode
[18] Fix | Delete
[19] Fix | Delete
def S_IMODE(mode):
[20] Fix | Delete
"""Return the portion of the file's mode that can be set by
[21] Fix | Delete
os.chmod().
[22] Fix | Delete
"""
[23] Fix | Delete
return mode & 0o7777
[24] Fix | Delete
[25] Fix | Delete
def S_IFMT(mode):
[26] Fix | Delete
"""Return the portion of the file's mode that describes the
[27] Fix | Delete
file type.
[28] Fix | Delete
"""
[29] Fix | Delete
return mode & 0o170000
[30] Fix | Delete
[31] Fix | Delete
# Constants used as S_IFMT() for various file types
[32] Fix | Delete
# (not all are implemented on all systems)
[33] Fix | Delete
[34] Fix | Delete
S_IFDIR = 0o040000 # directory
[35] Fix | Delete
S_IFCHR = 0o020000 # character device
[36] Fix | Delete
S_IFBLK = 0o060000 # block device
[37] Fix | Delete
S_IFREG = 0o100000 # regular file
[38] Fix | Delete
S_IFIFO = 0o010000 # fifo (named pipe)
[39] Fix | Delete
S_IFLNK = 0o120000 # symbolic link
[40] Fix | Delete
S_IFSOCK = 0o140000 # socket file
[41] Fix | Delete
[42] Fix | Delete
# Functions to test for each file type
[43] Fix | Delete
[44] Fix | Delete
def S_ISDIR(mode):
[45] Fix | Delete
"""Return True if mode is from a directory."""
[46] Fix | Delete
return S_IFMT(mode) == S_IFDIR
[47] Fix | Delete
[48] Fix | Delete
def S_ISCHR(mode):
[49] Fix | Delete
"""Return True if mode is from a character special device file."""
[50] Fix | Delete
return S_IFMT(mode) == S_IFCHR
[51] Fix | Delete
[52] Fix | Delete
def S_ISBLK(mode):
[53] Fix | Delete
"""Return True if mode is from a block special device file."""
[54] Fix | Delete
return S_IFMT(mode) == S_IFBLK
[55] Fix | Delete
[56] Fix | Delete
def S_ISREG(mode):
[57] Fix | Delete
"""Return True if mode is from a regular file."""
[58] Fix | Delete
return S_IFMT(mode) == S_IFREG
[59] Fix | Delete
[60] Fix | Delete
def S_ISFIFO(mode):
[61] Fix | Delete
"""Return True if mode is from a FIFO (named pipe)."""
[62] Fix | Delete
return S_IFMT(mode) == S_IFIFO
[63] Fix | Delete
[64] Fix | Delete
def S_ISLNK(mode):
[65] Fix | Delete
"""Return True if mode is from a symbolic link."""
[66] Fix | Delete
return S_IFMT(mode) == S_IFLNK
[67] Fix | Delete
[68] Fix | Delete
def S_ISSOCK(mode):
[69] Fix | Delete
"""Return True if mode is from a socket."""
[70] Fix | Delete
return S_IFMT(mode) == S_IFSOCK
[71] Fix | Delete
[72] Fix | Delete
# Names for permission bits
[73] Fix | Delete
[74] Fix | Delete
S_ISUID = 0o4000 # set UID bit
[75] Fix | Delete
S_ISGID = 0o2000 # set GID bit
[76] Fix | Delete
S_ENFMT = S_ISGID # file locking enforcement
[77] Fix | Delete
S_ISVTX = 0o1000 # sticky bit
[78] Fix | Delete
S_IREAD = 0o0400 # Unix V7 synonym for S_IRUSR
[79] Fix | Delete
S_IWRITE = 0o0200 # Unix V7 synonym for S_IWUSR
[80] Fix | Delete
S_IEXEC = 0o0100 # Unix V7 synonym for S_IXUSR
[81] Fix | Delete
S_IRWXU = 0o0700 # mask for owner permissions
[82] Fix | Delete
S_IRUSR = 0o0400 # read by owner
[83] Fix | Delete
S_IWUSR = 0o0200 # write by owner
[84] Fix | Delete
S_IXUSR = 0o0100 # execute by owner
[85] Fix | Delete
S_IRWXG = 0o0070 # mask for group permissions
[86] Fix | Delete
S_IRGRP = 0o0040 # read by group
[87] Fix | Delete
S_IWGRP = 0o0020 # write by group
[88] Fix | Delete
S_IXGRP = 0o0010 # execute by group
[89] Fix | Delete
S_IRWXO = 0o0007 # mask for others (not in group) permissions
[90] Fix | Delete
S_IROTH = 0o0004 # read by others
[91] Fix | Delete
S_IWOTH = 0o0002 # write by others
[92] Fix | Delete
S_IXOTH = 0o0001 # execute by others
[93] Fix | Delete
[94] Fix | Delete
# Names for file flags
[95] Fix | Delete
[96] Fix | Delete
UF_NODUMP = 0x00000001 # do not dump file
[97] Fix | Delete
UF_IMMUTABLE = 0x00000002 # file may not be changed
[98] Fix | Delete
UF_APPEND = 0x00000004 # file may only be appended to
[99] Fix | Delete
UF_OPAQUE = 0x00000008 # directory is opaque when viewed through a union stack
[100] Fix | Delete
UF_NOUNLINK = 0x00000010 # file may not be renamed or deleted
[101] Fix | Delete
UF_COMPRESSED = 0x00000020 # OS X: file is hfs-compressed
[102] Fix | Delete
UF_HIDDEN = 0x00008000 # OS X: file should not be displayed
[103] Fix | Delete
SF_ARCHIVED = 0x00010000 # file may be archived
[104] Fix | Delete
SF_IMMUTABLE = 0x00020000 # file may not be changed
[105] Fix | Delete
SF_APPEND = 0x00040000 # file may only be appended to
[106] Fix | Delete
SF_NOUNLINK = 0x00100000 # file may not be renamed or deleted
[107] Fix | Delete
SF_SNAPSHOT = 0x00200000 # file is a snapshot file
[108] Fix | Delete
[109] Fix | Delete
[110] Fix | Delete
_filemode_table = (
[111] Fix | Delete
((S_IFLNK, "l"),
[112] Fix | Delete
(S_IFREG, "-"),
[113] Fix | Delete
(S_IFBLK, "b"),
[114] Fix | Delete
(S_IFDIR, "d"),
[115] Fix | Delete
(S_IFCHR, "c"),
[116] Fix | Delete
(S_IFIFO, "p")),
[117] Fix | Delete
[118] Fix | Delete
((S_IRUSR, "r"),),
[119] Fix | Delete
((S_IWUSR, "w"),),
[120] Fix | Delete
((S_IXUSR|S_ISUID, "s"),
[121] Fix | Delete
(S_ISUID, "S"),
[122] Fix | Delete
(S_IXUSR, "x")),
[123] Fix | Delete
[124] Fix | Delete
((S_IRGRP, "r"),),
[125] Fix | Delete
((S_IWGRP, "w"),),
[126] Fix | Delete
((S_IXGRP|S_ISGID, "s"),
[127] Fix | Delete
(S_ISGID, "S"),
[128] Fix | Delete
(S_IXGRP, "x")),
[129] Fix | Delete
[130] Fix | Delete
((S_IROTH, "r"),),
[131] Fix | Delete
((S_IWOTH, "w"),),
[132] Fix | Delete
((S_IXOTH|S_ISVTX, "t"),
[133] Fix | Delete
(S_ISVTX, "T"),
[134] Fix | Delete
(S_IXOTH, "x"))
[135] Fix | Delete
)
[136] Fix | Delete
[137] Fix | Delete
def filemode(mode):
[138] Fix | Delete
"""Convert a file's mode to a string of the form '-rwxrwxrwx'."""
[139] Fix | Delete
perm = []
[140] Fix | Delete
for table in _filemode_table:
[141] Fix | Delete
for bit, char in table:
[142] Fix | Delete
if mode & bit == bit:
[143] Fix | Delete
perm.append(char)
[144] Fix | Delete
break
[145] Fix | Delete
else:
[146] Fix | Delete
perm.append("-")
[147] Fix | Delete
return "".join(perm)
[148] Fix | Delete
[149] Fix | Delete
[150] Fix | Delete
# Windows FILE_ATTRIBUTE constants for interpreting os.stat()'s
[151] Fix | Delete
# "st_file_attributes" member
[152] Fix | Delete
[153] Fix | Delete
FILE_ATTRIBUTE_ARCHIVE = 32
[154] Fix | Delete
FILE_ATTRIBUTE_COMPRESSED = 2048
[155] Fix | Delete
FILE_ATTRIBUTE_DEVICE = 64
[156] Fix | Delete
FILE_ATTRIBUTE_DIRECTORY = 16
[157] Fix | Delete
FILE_ATTRIBUTE_ENCRYPTED = 16384
[158] Fix | Delete
FILE_ATTRIBUTE_HIDDEN = 2
[159] Fix | Delete
FILE_ATTRIBUTE_INTEGRITY_STREAM = 32768
[160] Fix | Delete
FILE_ATTRIBUTE_NORMAL = 128
[161] Fix | Delete
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 8192
[162] Fix | Delete
FILE_ATTRIBUTE_NO_SCRUB_DATA = 131072
[163] Fix | Delete
FILE_ATTRIBUTE_OFFLINE = 4096
[164] Fix | Delete
FILE_ATTRIBUTE_READONLY = 1
[165] Fix | Delete
FILE_ATTRIBUTE_REPARSE_POINT = 1024
[166] Fix | Delete
FILE_ATTRIBUTE_SPARSE_FILE = 512
[167] Fix | Delete
FILE_ATTRIBUTE_SYSTEM = 4
[168] Fix | Delete
FILE_ATTRIBUTE_TEMPORARY = 256
[169] Fix | Delete
FILE_ATTRIBUTE_VIRTUAL = 65536
[170] Fix | Delete
[171] Fix | Delete
[172] Fix | Delete
# If available, use C implementation
[173] Fix | Delete
try:
[174] Fix | Delete
from _stat import *
[175] Fix | Delete
except ImportError:
[176] Fix | Delete
pass
[177] Fix | Delete
[178] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function