Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/imh-pyth.../lib/python3....
File: pathlib.py
import fnmatch
[0] Fix | Delete
import functools
[1] Fix | Delete
import io
[2] Fix | Delete
import ntpath
[3] Fix | Delete
import os
[4] Fix | Delete
import posixpath
[5] Fix | Delete
import re
[6] Fix | Delete
import sys
[7] Fix | Delete
from _collections_abc import Sequence
[8] Fix | Delete
from errno import EINVAL, ENOENT, ENOTDIR, EBADF, ELOOP
[9] Fix | Delete
from operator import attrgetter
[10] Fix | Delete
from stat import S_ISDIR, S_ISLNK, S_ISREG, S_ISSOCK, S_ISBLK, S_ISCHR, S_ISFIFO
[11] Fix | Delete
from urllib.parse import quote_from_bytes as urlquote_from_bytes
[12] Fix | Delete
[13] Fix | Delete
[14] Fix | Delete
supports_symlinks = True
[15] Fix | Delete
if os.name == 'nt':
[16] Fix | Delete
import nt
[17] Fix | Delete
if sys.getwindowsversion()[:2] >= (6, 0):
[18] Fix | Delete
from nt import _getfinalpathname
[19] Fix | Delete
else:
[20] Fix | Delete
supports_symlinks = False
[21] Fix | Delete
_getfinalpathname = None
[22] Fix | Delete
else:
[23] Fix | Delete
nt = None
[24] Fix | Delete
[25] Fix | Delete
[26] Fix | Delete
__all__ = [
[27] Fix | Delete
"PurePath", "PurePosixPath", "PureWindowsPath",
[28] Fix | Delete
"Path", "PosixPath", "WindowsPath",
[29] Fix | Delete
]
[30] Fix | Delete
[31] Fix | Delete
#
[32] Fix | Delete
# Internals
[33] Fix | Delete
#
[34] Fix | Delete
[35] Fix | Delete
# EBADF - guard against macOS `stat` throwing EBADF
[36] Fix | Delete
_IGNORED_ERROS = (ENOENT, ENOTDIR, EBADF, ELOOP)
[37] Fix | Delete
[38] Fix | Delete
_IGNORED_WINERRORS = (
[39] Fix | Delete
21, # ERROR_NOT_READY - drive exists but is not accessible
[40] Fix | Delete
123, # ERROR_INVALID_NAME - fix for bpo-35306
[41] Fix | Delete
1921, # ERROR_CANT_RESOLVE_FILENAME - fix for broken symlink pointing to itself
[42] Fix | Delete
)
[43] Fix | Delete
[44] Fix | Delete
def _ignore_error(exception):
[45] Fix | Delete
return (getattr(exception, 'errno', None) in _IGNORED_ERROS or
[46] Fix | Delete
getattr(exception, 'winerror', None) in _IGNORED_WINERRORS)
[47] Fix | Delete
[48] Fix | Delete
[49] Fix | Delete
def _is_wildcard_pattern(pat):
[50] Fix | Delete
# Whether this pattern needs actual matching using fnmatch, or can
[51] Fix | Delete
# be looked up directly as a file.
[52] Fix | Delete
return "*" in pat or "?" in pat or "[" in pat
[53] Fix | Delete
[54] Fix | Delete
[55] Fix | Delete
class _Flavour(object):
[56] Fix | Delete
"""A flavour implements a particular (platform-specific) set of path
[57] Fix | Delete
semantics."""
[58] Fix | Delete
[59] Fix | Delete
def __init__(self):
[60] Fix | Delete
self.join = self.sep.join
[61] Fix | Delete
[62] Fix | Delete
def parse_parts(self, parts):
[63] Fix | Delete
parsed = []
[64] Fix | Delete
sep = self.sep
[65] Fix | Delete
altsep = self.altsep
[66] Fix | Delete
drv = root = ''
[67] Fix | Delete
it = reversed(parts)
[68] Fix | Delete
for part in it:
[69] Fix | Delete
if not part:
[70] Fix | Delete
continue
[71] Fix | Delete
if altsep:
[72] Fix | Delete
part = part.replace(altsep, sep)
[73] Fix | Delete
drv, root, rel = self.splitroot(part)
[74] Fix | Delete
if sep in rel:
[75] Fix | Delete
for x in reversed(rel.split(sep)):
[76] Fix | Delete
if x and x != '.':
[77] Fix | Delete
parsed.append(sys.intern(x))
[78] Fix | Delete
else:
[79] Fix | Delete
if rel and rel != '.':
[80] Fix | Delete
parsed.append(sys.intern(rel))
[81] Fix | Delete
if drv or root:
[82] Fix | Delete
if not drv:
[83] Fix | Delete
# If no drive is present, try to find one in the previous
[84] Fix | Delete
# parts. This makes the result of parsing e.g.
[85] Fix | Delete
# ("C:", "/", "a") reasonably intuitive.
[86] Fix | Delete
for part in it:
[87] Fix | Delete
if not part:
[88] Fix | Delete
continue
[89] Fix | Delete
if altsep:
[90] Fix | Delete
part = part.replace(altsep, sep)
[91] Fix | Delete
drv = self.splitroot(part)[0]
[92] Fix | Delete
if drv:
[93] Fix | Delete
break
[94] Fix | Delete
break
[95] Fix | Delete
if drv or root:
[96] Fix | Delete
parsed.append(drv + root)
[97] Fix | Delete
parsed.reverse()
[98] Fix | Delete
return drv, root, parsed
[99] Fix | Delete
[100] Fix | Delete
def join_parsed_parts(self, drv, root, parts, drv2, root2, parts2):
[101] Fix | Delete
"""
[102] Fix | Delete
Join the two paths represented by the respective
[103] Fix | Delete
(drive, root, parts) tuples. Return a new (drive, root, parts) tuple.
[104] Fix | Delete
"""
[105] Fix | Delete
if root2:
[106] Fix | Delete
if not drv2 and drv:
[107] Fix | Delete
return drv, root2, [drv + root2] + parts2[1:]
[108] Fix | Delete
elif drv2:
[109] Fix | Delete
if drv2 == drv or self.casefold(drv2) == self.casefold(drv):
[110] Fix | Delete
# Same drive => second path is relative to the first
[111] Fix | Delete
return drv, root, parts + parts2[1:]
[112] Fix | Delete
else:
[113] Fix | Delete
# Second path is non-anchored (common case)
[114] Fix | Delete
return drv, root, parts + parts2
[115] Fix | Delete
return drv2, root2, parts2
[116] Fix | Delete
[117] Fix | Delete
[118] Fix | Delete
class _WindowsFlavour(_Flavour):
[119] Fix | Delete
# Reference for Windows paths can be found at
[120] Fix | Delete
# http://msdn.microsoft.com/en-us/library/aa365247%28v=vs.85%29.aspx
[121] Fix | Delete
[122] Fix | Delete
sep = '\\'
[123] Fix | Delete
altsep = '/'
[124] Fix | Delete
has_drv = True
[125] Fix | Delete
pathmod = ntpath
[126] Fix | Delete
[127] Fix | Delete
is_supported = (os.name == 'nt')
[128] Fix | Delete
[129] Fix | Delete
drive_letters = set('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
[130] Fix | Delete
ext_namespace_prefix = '\\\\?\\'
[131] Fix | Delete
[132] Fix | Delete
reserved_names = (
[133] Fix | Delete
{'CON', 'PRN', 'AUX', 'NUL', 'CONIN$', 'CONOUT$'} |
[134] Fix | Delete
{'COM%s' % c for c in '123456789\xb9\xb2\xb3'} |
[135] Fix | Delete
{'LPT%s' % c for c in '123456789\xb9\xb2\xb3'}
[136] Fix | Delete
)
[137] Fix | Delete
[138] Fix | Delete
# Interesting findings about extended paths:
[139] Fix | Delete
# * '\\?\c:\a' is an extended path, which bypasses normal Windows API
[140] Fix | Delete
# path processing. Thus relative paths are not resolved and slash is not
[141] Fix | Delete
# translated to backslash. It has the native NT path limit of 32767
[142] Fix | Delete
# characters, but a bit less after resolving device symbolic links,
[143] Fix | Delete
# such as '\??\C:' => '\Device\HarddiskVolume2'.
[144] Fix | Delete
# * '\\?\c:/a' looks for a device named 'C:/a' because slash is a
[145] Fix | Delete
# regular name character in the object namespace.
[146] Fix | Delete
# * '\\?\c:\foo/bar' is invalid because '/' is illegal in NT filesystems.
[147] Fix | Delete
# The only path separator at the filesystem level is backslash.
[148] Fix | Delete
# * '//?/c:\a' and '//?/c:/a' are effectively equivalent to '\\.\c:\a' and
[149] Fix | Delete
# thus limited to MAX_PATH.
[150] Fix | Delete
# * Prior to Windows 8, ANSI API bytes paths are limited to MAX_PATH,
[151] Fix | Delete
# even with the '\\?\' prefix.
[152] Fix | Delete
[153] Fix | Delete
def splitroot(self, part, sep=sep):
[154] Fix | Delete
first = part[0:1]
[155] Fix | Delete
second = part[1:2]
[156] Fix | Delete
if (second == sep and first == sep):
[157] Fix | Delete
# XXX extended paths should also disable the collapsing of "."
[158] Fix | Delete
# components (according to MSDN docs).
[159] Fix | Delete
prefix, part = self._split_extended_path(part)
[160] Fix | Delete
first = part[0:1]
[161] Fix | Delete
second = part[1:2]
[162] Fix | Delete
else:
[163] Fix | Delete
prefix = ''
[164] Fix | Delete
third = part[2:3]
[165] Fix | Delete
if (second == sep and first == sep and third != sep):
[166] Fix | Delete
# is a UNC path:
[167] Fix | Delete
# vvvvvvvvvvvvvvvvvvvvv root
[168] Fix | Delete
# \\machine\mountpoint\directory\etc\...
[169] Fix | Delete
# directory ^^^^^^^^^^^^^^
[170] Fix | Delete
index = part.find(sep, 2)
[171] Fix | Delete
if index != -1:
[172] Fix | Delete
index2 = part.find(sep, index + 1)
[173] Fix | Delete
# a UNC path can't have two slashes in a row
[174] Fix | Delete
# (after the initial two)
[175] Fix | Delete
if index2 != index + 1:
[176] Fix | Delete
if index2 == -1:
[177] Fix | Delete
index2 = len(part)
[178] Fix | Delete
if prefix:
[179] Fix | Delete
return prefix + part[1:index2], sep, part[index2+1:]
[180] Fix | Delete
else:
[181] Fix | Delete
return part[:index2], sep, part[index2+1:]
[182] Fix | Delete
drv = root = ''
[183] Fix | Delete
if second == ':' and first in self.drive_letters:
[184] Fix | Delete
drv = part[:2]
[185] Fix | Delete
part = part[2:]
[186] Fix | Delete
first = third
[187] Fix | Delete
if first == sep:
[188] Fix | Delete
root = first
[189] Fix | Delete
part = part.lstrip(sep)
[190] Fix | Delete
return prefix + drv, root, part
[191] Fix | Delete
[192] Fix | Delete
def casefold(self, s):
[193] Fix | Delete
return s.lower()
[194] Fix | Delete
[195] Fix | Delete
def casefold_parts(self, parts):
[196] Fix | Delete
return [p.lower() for p in parts]
[197] Fix | Delete
[198] Fix | Delete
def compile_pattern(self, pattern):
[199] Fix | Delete
return re.compile(fnmatch.translate(pattern), re.IGNORECASE).fullmatch
[200] Fix | Delete
[201] Fix | Delete
def resolve(self, path, strict=False):
[202] Fix | Delete
s = str(path)
[203] Fix | Delete
if not s:
[204] Fix | Delete
return os.getcwd()
[205] Fix | Delete
previous_s = None
[206] Fix | Delete
if _getfinalpathname is not None:
[207] Fix | Delete
if strict:
[208] Fix | Delete
return self._ext_to_normal(_getfinalpathname(s))
[209] Fix | Delete
else:
[210] Fix | Delete
tail_parts = [] # End of the path after the first one not found
[211] Fix | Delete
while True:
[212] Fix | Delete
try:
[213] Fix | Delete
s = self._ext_to_normal(_getfinalpathname(s))
[214] Fix | Delete
except FileNotFoundError:
[215] Fix | Delete
previous_s = s
[216] Fix | Delete
s, tail = os.path.split(s)
[217] Fix | Delete
tail_parts.append(tail)
[218] Fix | Delete
if previous_s == s:
[219] Fix | Delete
return path
[220] Fix | Delete
else:
[221] Fix | Delete
return os.path.join(s, *reversed(tail_parts))
[222] Fix | Delete
# Means fallback on absolute
[223] Fix | Delete
return None
[224] Fix | Delete
[225] Fix | Delete
def _split_extended_path(self, s, ext_prefix=ext_namespace_prefix):
[226] Fix | Delete
prefix = ''
[227] Fix | Delete
if s.startswith(ext_prefix):
[228] Fix | Delete
prefix = s[:4]
[229] Fix | Delete
s = s[4:]
[230] Fix | Delete
if s.startswith('UNC\\'):
[231] Fix | Delete
prefix += s[:3]
[232] Fix | Delete
s = '\\' + s[3:]
[233] Fix | Delete
return prefix, s
[234] Fix | Delete
[235] Fix | Delete
def _ext_to_normal(self, s):
[236] Fix | Delete
# Turn back an extended path into a normal DOS-like path
[237] Fix | Delete
return self._split_extended_path(s)[1]
[238] Fix | Delete
[239] Fix | Delete
def is_reserved(self, parts):
[240] Fix | Delete
# NOTE: the rules for reserved names seem somewhat complicated
[241] Fix | Delete
# (e.g. r"..\NUL" is reserved but not r"foo\NUL" if "foo" does not
[242] Fix | Delete
# exist). We err on the side of caution and return True for paths
[243] Fix | Delete
# which are not considered reserved by Windows.
[244] Fix | Delete
if not parts:
[245] Fix | Delete
return False
[246] Fix | Delete
if parts[0].startswith('\\\\'):
[247] Fix | Delete
# UNC paths are never reserved
[248] Fix | Delete
return False
[249] Fix | Delete
name = parts[-1].partition('.')[0].partition(':')[0].rstrip(' ')
[250] Fix | Delete
return name.upper() in self.reserved_names
[251] Fix | Delete
[252] Fix | Delete
def make_uri(self, path):
[253] Fix | Delete
# Under Windows, file URIs use the UTF-8 encoding.
[254] Fix | Delete
drive = path.drive
[255] Fix | Delete
if len(drive) == 2 and drive[1] == ':':
[256] Fix | Delete
# It's a path on a local drive => 'file:///c:/a/b'
[257] Fix | Delete
rest = path.as_posix()[2:].lstrip('/')
[258] Fix | Delete
return 'file:///%s/%s' % (
[259] Fix | Delete
drive, urlquote_from_bytes(rest.encode('utf-8')))
[260] Fix | Delete
else:
[261] Fix | Delete
# It's a path on a network drive => 'file://host/share/a/b'
[262] Fix | Delete
return 'file:' + urlquote_from_bytes(path.as_posix().encode('utf-8'))
[263] Fix | Delete
[264] Fix | Delete
def gethomedir(self, username):
[265] Fix | Delete
if 'USERPROFILE' in os.environ:
[266] Fix | Delete
userhome = os.environ['USERPROFILE']
[267] Fix | Delete
elif 'HOMEPATH' in os.environ:
[268] Fix | Delete
try:
[269] Fix | Delete
drv = os.environ['HOMEDRIVE']
[270] Fix | Delete
except KeyError:
[271] Fix | Delete
drv = ''
[272] Fix | Delete
userhome = drv + os.environ['HOMEPATH']
[273] Fix | Delete
else:
[274] Fix | Delete
raise RuntimeError("Can't determine home directory")
[275] Fix | Delete
[276] Fix | Delete
if username:
[277] Fix | Delete
# Try to guess user home directory. By default all users
[278] Fix | Delete
# directories are located in the same place and are named by
[279] Fix | Delete
# corresponding usernames. If current user home directory points
[280] Fix | Delete
# to nonstandard place, this guess is likely wrong.
[281] Fix | Delete
if os.environ['USERNAME'] != username:
[282] Fix | Delete
drv, root, parts = self.parse_parts((userhome,))
[283] Fix | Delete
if parts[-1] != os.environ['USERNAME']:
[284] Fix | Delete
raise RuntimeError("Can't determine home directory "
[285] Fix | Delete
"for %r" % username)
[286] Fix | Delete
parts[-1] = username
[287] Fix | Delete
if drv or root:
[288] Fix | Delete
userhome = drv + root + self.join(parts[1:])
[289] Fix | Delete
else:
[290] Fix | Delete
userhome = self.join(parts)
[291] Fix | Delete
return userhome
[292] Fix | Delete
[293] Fix | Delete
class _PosixFlavour(_Flavour):
[294] Fix | Delete
sep = '/'
[295] Fix | Delete
altsep = ''
[296] Fix | Delete
has_drv = False
[297] Fix | Delete
pathmod = posixpath
[298] Fix | Delete
[299] Fix | Delete
is_supported = (os.name != 'nt')
[300] Fix | Delete
[301] Fix | Delete
def splitroot(self, part, sep=sep):
[302] Fix | Delete
if part and part[0] == sep:
[303] Fix | Delete
stripped_part = part.lstrip(sep)
[304] Fix | Delete
# According to POSIX path resolution:
[305] Fix | Delete
# http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html#tag_04_11
[306] Fix | Delete
# "A pathname that begins with two successive slashes may be
[307] Fix | Delete
# interpreted in an implementation-defined manner, although more
[308] Fix | Delete
# than two leading slashes shall be treated as a single slash".
[309] Fix | Delete
if len(part) - len(stripped_part) == 2:
[310] Fix | Delete
return '', sep * 2, stripped_part
[311] Fix | Delete
else:
[312] Fix | Delete
return '', sep, stripped_part
[313] Fix | Delete
else:
[314] Fix | Delete
return '', '', part
[315] Fix | Delete
[316] Fix | Delete
def casefold(self, s):
[317] Fix | Delete
return s
[318] Fix | Delete
[319] Fix | Delete
def casefold_parts(self, parts):
[320] Fix | Delete
return parts
[321] Fix | Delete
[322] Fix | Delete
def compile_pattern(self, pattern):
[323] Fix | Delete
return re.compile(fnmatch.translate(pattern)).fullmatch
[324] Fix | Delete
[325] Fix | Delete
def resolve(self, path, strict=False):
[326] Fix | Delete
sep = self.sep
[327] Fix | Delete
accessor = path._accessor
[328] Fix | Delete
seen = {}
[329] Fix | Delete
def _resolve(path, rest):
[330] Fix | Delete
if rest.startswith(sep):
[331] Fix | Delete
path = ''
[332] Fix | Delete
[333] Fix | Delete
for name in rest.split(sep):
[334] Fix | Delete
if not name or name == '.':
[335] Fix | Delete
# current dir
[336] Fix | Delete
continue
[337] Fix | Delete
if name == '..':
[338] Fix | Delete
# parent dir
[339] Fix | Delete
path, _, _ = path.rpartition(sep)
[340] Fix | Delete
continue
[341] Fix | Delete
if path.endswith(sep):
[342] Fix | Delete
newpath = path + name
[343] Fix | Delete
else:
[344] Fix | Delete
newpath = path + sep + name
[345] Fix | Delete
if newpath in seen:
[346] Fix | Delete
# Already seen this path
[347] Fix | Delete
path = seen[newpath]
[348] Fix | Delete
if path is not None:
[349] Fix | Delete
# use cached value
[350] Fix | Delete
continue
[351] Fix | Delete
# The symlink is not resolved, so we must have a symlink loop.
[352] Fix | Delete
raise RuntimeError("Symlink loop from %r" % newpath)
[353] Fix | Delete
# Resolve the symbolic link
[354] Fix | Delete
try:
[355] Fix | Delete
target = accessor.readlink(newpath)
[356] Fix | Delete
except OSError as e:
[357] Fix | Delete
if e.errno != EINVAL and strict:
[358] Fix | Delete
raise
[359] Fix | Delete
# Not a symlink, or non-strict mode. We just leave the path
[360] Fix | Delete
# untouched.
[361] Fix | Delete
path = newpath
[362] Fix | Delete
else:
[363] Fix | Delete
seen[newpath] = None # not resolved symlink
[364] Fix | Delete
path = _resolve(path, target)
[365] Fix | Delete
seen[newpath] = path # resolved symlink
[366] Fix | Delete
[367] Fix | Delete
return path
[368] Fix | Delete
# NOTE: according to POSIX, getcwd() cannot contain path components
[369] Fix | Delete
# which are symlinks.
[370] Fix | Delete
base = '' if path.is_absolute() else os.getcwd()
[371] Fix | Delete
return _resolve(base, str(path)) or sep
[372] Fix | Delete
[373] Fix | Delete
def is_reserved(self, parts):
[374] Fix | Delete
return False
[375] Fix | Delete
[376] Fix | Delete
def make_uri(self, path):
[377] Fix | Delete
# We represent the path using the local filesystem encoding,
[378] Fix | Delete
# for portability to other applications.
[379] Fix | Delete
bpath = bytes(path)
[380] Fix | Delete
return 'file://' + urlquote_from_bytes(bpath)
[381] Fix | Delete
[382] Fix | Delete
def gethomedir(self, username):
[383] Fix | Delete
if not username:
[384] Fix | Delete
try:
[385] Fix | Delete
return os.environ['HOME']
[386] Fix | Delete
except KeyError:
[387] Fix | Delete
import pwd
[388] Fix | Delete
return pwd.getpwuid(os.getuid()).pw_dir
[389] Fix | Delete
else:
[390] Fix | Delete
import pwd
[391] Fix | Delete
try:
[392] Fix | Delete
return pwd.getpwnam(username).pw_dir
[393] Fix | Delete
except KeyError:
[394] Fix | Delete
raise RuntimeError("Can't determine home directory "
[395] Fix | Delete
"for %r" % username)
[396] Fix | Delete
[397] Fix | Delete
[398] Fix | Delete
_windows_flavour = _WindowsFlavour()
[399] Fix | Delete
_posix_flavour = _PosixFlavour()
[400] Fix | Delete
[401] Fix | Delete
[402] Fix | Delete
class _Accessor:
[403] Fix | Delete
"""An accessor implements a particular (system-specific or not) way of
[404] Fix | Delete
accessing paths on the filesystem."""
[405] Fix | Delete
[406] Fix | Delete
[407] Fix | Delete
class _NormalAccessor(_Accessor):
[408] Fix | Delete
[409] Fix | Delete
stat = os.stat
[410] Fix | Delete
[411] Fix | Delete
lstat = os.lstat
[412] Fix | Delete
[413] Fix | Delete
open = os.open
[414] Fix | Delete
[415] Fix | Delete
listdir = os.listdir
[416] Fix | Delete
[417] Fix | Delete
scandir = os.scandir
[418] Fix | Delete
[419] Fix | Delete
chmod = os.chmod
[420] Fix | Delete
[421] Fix | Delete
if hasattr(os, "lchmod"):
[422] Fix | Delete
lchmod = os.lchmod
[423] Fix | Delete
else:
[424] Fix | Delete
def lchmod(self, pathobj, mode):
[425] Fix | Delete
raise NotImplementedError("lchmod() not available on this system")
[426] Fix | Delete
[427] Fix | Delete
mkdir = os.mkdir
[428] Fix | Delete
[429] Fix | Delete
unlink = os.unlink
[430] Fix | Delete
[431] Fix | Delete
if hasattr(os, "link"):
[432] Fix | Delete
link_to = os.link
[433] Fix | Delete
else:
[434] Fix | Delete
@staticmethod
[435] Fix | Delete
def link_to(self, target):
[436] Fix | Delete
raise NotImplementedError("os.link() not available on this system")
[437] Fix | Delete
[438] Fix | Delete
rmdir = os.rmdir
[439] Fix | Delete
[440] Fix | Delete
rename = os.rename
[441] Fix | Delete
[442] Fix | Delete
replace = os.replace
[443] Fix | Delete
[444] Fix | Delete
if nt:
[445] Fix | Delete
if supports_symlinks:
[446] Fix | Delete
symlink = os.symlink
[447] Fix | Delete
else:
[448] Fix | Delete
def symlink(a, b, target_is_directory):
[449] Fix | Delete
raise NotImplementedError("symlink() not available on this system")
[450] Fix | Delete
else:
[451] Fix | Delete
# Under POSIX, os.symlink() takes two args
[452] Fix | Delete
@staticmethod
[453] Fix | Delete
def symlink(a, b, target_is_directory):
[454] Fix | Delete
return os.symlink(a, b)
[455] Fix | Delete
[456] Fix | Delete
utime = os.utime
[457] Fix | Delete
[458] Fix | Delete
# Helper for resolve()
[459] Fix | Delete
def readlink(self, path):
[460] Fix | Delete
return os.readlink(path)
[461] Fix | Delete
[462] Fix | Delete
def owner(self, path):
[463] Fix | Delete
try:
[464] Fix | Delete
import pwd
[465] Fix | Delete
return pwd.getpwuid(self.stat(path).st_uid).pw_name
[466] Fix | Delete
except ImportError:
[467] Fix | Delete
raise NotImplementedError("Path.owner() is unsupported on this system")
[468] Fix | Delete
[469] Fix | Delete
def group(self, path):
[470] Fix | Delete
try:
[471] Fix | Delete
import grp
[472] Fix | Delete
return grp.getgrgid(self.stat(path).st_gid).gr_name
[473] Fix | Delete
except ImportError:
[474] Fix | Delete
raise NotImplementedError("Path.group() is unsupported on this system")
[475] Fix | Delete
[476] Fix | Delete
[477] Fix | Delete
_normal_accessor = _NormalAccessor()
[478] Fix | Delete
[479] Fix | Delete
[480] Fix | Delete
#
[481] Fix | Delete
# Globbing helpers
[482] Fix | Delete
#
[483] Fix | Delete
[484] Fix | Delete
def _make_selector(pattern_parts, flavour):
[485] Fix | Delete
pat = pattern_parts[0]
[486] Fix | Delete
child_parts = pattern_parts[1:]
[487] Fix | Delete
if pat == '**':
[488] Fix | Delete
cls = _RecursiveWildcardSelector
[489] Fix | Delete
elif '**' in pat:
[490] Fix | Delete
raise ValueError("Invalid pattern: '**' can only be an entire path component")
[491] Fix | Delete
elif _is_wildcard_pattern(pat):
[492] Fix | Delete
cls = _WildcardSelector
[493] Fix | Delete
else:
[494] Fix | Delete
cls = _PreciseSelector
[495] Fix | Delete
return cls(pat, child_parts, flavour)
[496] Fix | Delete
[497] Fix | Delete
if hasattr(functools, "lru_cache"):
[498] Fix | Delete
_make_selector = functools.lru_cache()(_make_selector)
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function