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
# Fallbacks for uncommon platform-specific constants
[42] Fix | Delete
S_IFDOOR = 0
[43] Fix | Delete
S_IFPORT = 0
[44] Fix | Delete
S_IFWHT = 0
[45] Fix | Delete
[46] Fix | Delete
# Functions to test for each file type
[47] Fix | Delete
[48] Fix | Delete
def S_ISDIR(mode):
[49] Fix | Delete
"""Return True if mode is from a directory."""
[50] Fix | Delete
return S_IFMT(mode) == S_IFDIR
[51] Fix | Delete
[52] Fix | Delete
def S_ISCHR(mode):
[53] Fix | Delete
"""Return True if mode is from a character special device file."""
[54] Fix | Delete
return S_IFMT(mode) == S_IFCHR
[55] Fix | Delete
[56] Fix | Delete
def S_ISBLK(mode):
[57] Fix | Delete
"""Return True if mode is from a block special device file."""
[58] Fix | Delete
return S_IFMT(mode) == S_IFBLK
[59] Fix | Delete
[60] Fix | Delete
def S_ISREG(mode):
[61] Fix | Delete
"""Return True if mode is from a regular file."""
[62] Fix | Delete
return S_IFMT(mode) == S_IFREG
[63] Fix | Delete
[64] Fix | Delete
def S_ISFIFO(mode):
[65] Fix | Delete
"""Return True if mode is from a FIFO (named pipe)."""
[66] Fix | Delete
return S_IFMT(mode) == S_IFIFO
[67] Fix | Delete
[68] Fix | Delete
def S_ISLNK(mode):
[69] Fix | Delete
"""Return True if mode is from a symbolic link."""
[70] Fix | Delete
return S_IFMT(mode) == S_IFLNK
[71] Fix | Delete
[72] Fix | Delete
def S_ISSOCK(mode):
[73] Fix | Delete
"""Return True if mode is from a socket."""
[74] Fix | Delete
return S_IFMT(mode) == S_IFSOCK
[75] Fix | Delete
[76] Fix | Delete
def S_ISDOOR(mode):
[77] Fix | Delete
"""Return True if mode is from a door."""
[78] Fix | Delete
return False
[79] Fix | Delete
[80] Fix | Delete
def S_ISPORT(mode):
[81] Fix | Delete
"""Return True if mode is from an event port."""
[82] Fix | Delete
return False
[83] Fix | Delete
[84] Fix | Delete
def S_ISWHT(mode):
[85] Fix | Delete
"""Return True if mode is from a whiteout."""
[86] Fix | Delete
return False
[87] Fix | Delete
[88] Fix | Delete
# Names for permission bits
[89] Fix | Delete
[90] Fix | Delete
S_ISUID = 0o4000 # set UID bit
[91] Fix | Delete
S_ISGID = 0o2000 # set GID bit
[92] Fix | Delete
S_ENFMT = S_ISGID # file locking enforcement
[93] Fix | Delete
S_ISVTX = 0o1000 # sticky bit
[94] Fix | Delete
S_IREAD = 0o0400 # Unix V7 synonym for S_IRUSR
[95] Fix | Delete
S_IWRITE = 0o0200 # Unix V7 synonym for S_IWUSR
[96] Fix | Delete
S_IEXEC = 0o0100 # Unix V7 synonym for S_IXUSR
[97] Fix | Delete
S_IRWXU = 0o0700 # mask for owner permissions
[98] Fix | Delete
S_IRUSR = 0o0400 # read by owner
[99] Fix | Delete
S_IWUSR = 0o0200 # write by owner
[100] Fix | Delete
S_IXUSR = 0o0100 # execute by owner
[101] Fix | Delete
S_IRWXG = 0o0070 # mask for group permissions
[102] Fix | Delete
S_IRGRP = 0o0040 # read by group
[103] Fix | Delete
S_IWGRP = 0o0020 # write by group
[104] Fix | Delete
S_IXGRP = 0o0010 # execute by group
[105] Fix | Delete
S_IRWXO = 0o0007 # mask for others (not in group) permissions
[106] Fix | Delete
S_IROTH = 0o0004 # read by others
[107] Fix | Delete
S_IWOTH = 0o0002 # write by others
[108] Fix | Delete
S_IXOTH = 0o0001 # execute by others
[109] Fix | Delete
[110] Fix | Delete
# Names for file flags
[111] Fix | Delete
[112] Fix | Delete
UF_NODUMP = 0x00000001 # do not dump file
[113] Fix | Delete
UF_IMMUTABLE = 0x00000002 # file may not be changed
[114] Fix | Delete
UF_APPEND = 0x00000004 # file may only be appended to
[115] Fix | Delete
UF_OPAQUE = 0x00000008 # directory is opaque when viewed through a union stack
[116] Fix | Delete
UF_NOUNLINK = 0x00000010 # file may not be renamed or deleted
[117] Fix | Delete
UF_COMPRESSED = 0x00000020 # OS X: file is hfs-compressed
[118] Fix | Delete
UF_HIDDEN = 0x00008000 # OS X: file should not be displayed
[119] Fix | Delete
SF_ARCHIVED = 0x00010000 # file may be archived
[120] Fix | Delete
SF_IMMUTABLE = 0x00020000 # file may not be changed
[121] Fix | Delete
SF_APPEND = 0x00040000 # file may only be appended to
[122] Fix | Delete
SF_NOUNLINK = 0x00100000 # file may not be renamed or deleted
[123] Fix | Delete
SF_SNAPSHOT = 0x00200000 # file is a snapshot file
[124] Fix | Delete
[125] Fix | Delete
[126] Fix | Delete
_filemode_table = (
[127] Fix | Delete
((S_IFLNK, "l"),
[128] Fix | Delete
(S_IFSOCK, "s"), # Must appear before IFREG and IFDIR as IFSOCK == IFREG | IFDIR
[129] Fix | Delete
(S_IFREG, "-"),
[130] Fix | Delete
(S_IFBLK, "b"),
[131] Fix | Delete
(S_IFDIR, "d"),
[132] Fix | Delete
(S_IFCHR, "c"),
[133] Fix | Delete
(S_IFIFO, "p")),
[134] Fix | Delete
[135] Fix | Delete
((S_IRUSR, "r"),),
[136] Fix | Delete
((S_IWUSR, "w"),),
[137] Fix | Delete
((S_IXUSR|S_ISUID, "s"),
[138] Fix | Delete
(S_ISUID, "S"),
[139] Fix | Delete
(S_IXUSR, "x")),
[140] Fix | Delete
[141] Fix | Delete
((S_IRGRP, "r"),),
[142] Fix | Delete
((S_IWGRP, "w"),),
[143] Fix | Delete
((S_IXGRP|S_ISGID, "s"),
[144] Fix | Delete
(S_ISGID, "S"),
[145] Fix | Delete
(S_IXGRP, "x")),
[146] Fix | Delete
[147] Fix | Delete
((S_IROTH, "r"),),
[148] Fix | Delete
((S_IWOTH, "w"),),
[149] Fix | Delete
((S_IXOTH|S_ISVTX, "t"),
[150] Fix | Delete
(S_ISVTX, "T"),
[151] Fix | Delete
(S_IXOTH, "x"))
[152] Fix | Delete
)
[153] Fix | Delete
[154] Fix | Delete
def filemode(mode):
[155] Fix | Delete
"""Convert a file's mode to a string of the form '-rwxrwxrwx'."""
[156] Fix | Delete
perm = []
[157] Fix | Delete
for table in _filemode_table:
[158] Fix | Delete
for bit, char in table:
[159] Fix | Delete
if mode & bit == bit:
[160] Fix | Delete
perm.append(char)
[161] Fix | Delete
break
[162] Fix | Delete
else:
[163] Fix | Delete
perm.append("-")
[164] Fix | Delete
return "".join(perm)
[165] Fix | Delete
[166] Fix | Delete
[167] Fix | Delete
# Windows FILE_ATTRIBUTE constants for interpreting os.stat()'s
[168] Fix | Delete
# "st_file_attributes" member
[169] Fix | Delete
[170] Fix | Delete
FILE_ATTRIBUTE_ARCHIVE = 32
[171] Fix | Delete
FILE_ATTRIBUTE_COMPRESSED = 2048
[172] Fix | Delete
FILE_ATTRIBUTE_DEVICE = 64
[173] Fix | Delete
FILE_ATTRIBUTE_DIRECTORY = 16
[174] Fix | Delete
FILE_ATTRIBUTE_ENCRYPTED = 16384
[175] Fix | Delete
FILE_ATTRIBUTE_HIDDEN = 2
[176] Fix | Delete
FILE_ATTRIBUTE_INTEGRITY_STREAM = 32768
[177] Fix | Delete
FILE_ATTRIBUTE_NORMAL = 128
[178] Fix | Delete
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 8192
[179] Fix | Delete
FILE_ATTRIBUTE_NO_SCRUB_DATA = 131072
[180] Fix | Delete
FILE_ATTRIBUTE_OFFLINE = 4096
[181] Fix | Delete
FILE_ATTRIBUTE_READONLY = 1
[182] Fix | Delete
FILE_ATTRIBUTE_REPARSE_POINT = 1024
[183] Fix | Delete
FILE_ATTRIBUTE_SPARSE_FILE = 512
[184] Fix | Delete
FILE_ATTRIBUTE_SYSTEM = 4
[185] Fix | Delete
FILE_ATTRIBUTE_TEMPORARY = 256
[186] Fix | Delete
FILE_ATTRIBUTE_VIRTUAL = 65536
[187] Fix | Delete
[188] Fix | Delete
[189] Fix | Delete
# If available, use C implementation
[190] Fix | Delete
try:
[191] Fix | Delete
from _stat import *
[192] Fix | Delete
except ImportError:
[193] Fix | Delete
pass
[194] Fix | Delete
[195] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function