Lines Matching +full:p +full:- +full:try
1 # Module 'ntpath' -- common operations on WinNT/Win95 pathnames
8 # strings representing various path-related bits and pieces
45 try:
84 # volume), or if a pathname after the volume-letter-and-colon or UNC-resource
117 try:
119 path[:0] + sep #23780: Ensure compatible data type even if p is null.
121 for p in map(os.fspath, paths):
122 p_drive, p_path = splitdrive(p)
138 if result_path and result_path[-1] not in seps:
141 ## add separator between UNC and non-absolute path
143 result_drive and result_drive[-1:] != colon):
153 # It is always true that drivespec + pathspec == p
154 def splitdrive(p): argument
156 Returns a 2-tuple (drive_or_unc, path); either part may be empty.
159 result = splitdrive(p)
161 result[0] + result[1] == p
173 p = os.fspath(p)
174 if len(p) >= 2:
175 if isinstance(p, bytes):
185 normp = p.replace(altsep, sep)
191 if index == -1:
192 return p, p[:0]
194 if index2 == -1:
195 return p, p[:0]
196 return p[:index2], p[index2:]
198 # Drive-letter drives, e.g. X:
199 return p[:2], p[2:]
200 return p[:0], p
205 # join(head, tail) == p holds.
208 def split(p): argument
213 p = os.fspath(p)
214 seps = _get_bothseps(p)
215 d, p = splitdrive(p)
216 # set i to index beyond p's last slash
217 i = len(p)
218 while i and p[i-1] not in seps:
219 i -= 1
220 head, tail = p[:i], p[i:] # now tail has no slashes
229 # It is always true that root + ext == p.
231 def splitext(p): argument
232 p = os.fspath(p)
233 if isinstance(p, bytes):
234 return genericpath._splitext(p, b'\\', b'/', b'.')
236 return genericpath._splitext(p, '\\', '/', '.')
242 def basename(p): argument
244 return split(p)[1]
249 def dirname(p): argument
251 return split(p)[0]
260 try:
270 try:
286 try:
316 # (A function should also be defined to do full *sh-style environment
339 try:
352 # Try to guess user home directory. By default all user
369 # - no expansion within single quotes
370 # - '$$' is translated into '$'
371 # - '%%' is translated into '%' if '%%' are not seen in %var1%%var2%
372 # - ${varname} is accepted.
373 # - $varname is accepted.
374 # - %varname% is accepted.
375 # - varnames can be made out of letters, digits and the characters '_-'
389 varchars = bytes(string.ascii_letters + string.digits + '_-', 'ascii')
400 varchars = string.ascii_letters + string.digits + '_-'
415 try:
420 index = pathlen - 1
428 try:
432 index = pathlen - 1
435 try:
450 try:
454 index = pathlen - 1
457 try:
473 try:
482 index -= 1
492 try:
523 if i > 0 and comps[i-1] != pardir:
524 del comps[i-1:i+1]
525 i -= 1
548 `nt._getfullpathname` is not available or raises OSError. See bpo-31047 for
563 try:
566 except ImportError: # not running on Windows - mock up something sensible
572 try:
577 try:
580 # realpath is a no-op on systems without _getfinalpathname support.
603 try:
645 # Non-strict algorithm is to find as much of the target directory
649 try:
655 try:
666 # TODO (bpo-38186): Request the real file name from the directory
681 # bpo-38081: Special case for realpath(b'nul')
689 # bpo-38081: Special case for realpath('nul')
695 try:
703 # The path returned by _getfinalpathname will always start with \\?\ -
713 # Ensure that the non-prefixed path resolves to the same path
714 try:
748 try:
766 rel_list = [pardir] * (len(start_list)-i) + path_list[i:]
775 # Return the longest common sub-path of the sequence of paths given as input.
776 # The function is case-insensitive and 'separator-insensitive', i.e. if the
786 """Given a sequence of path names, returns the longest common sub-path."""
801 try:
802 drivesplits = [splitdrive(p.replace(altsep, sep).lower()) for p in paths]
803 split_paths = [p.split(sep) for d, p in drivesplits]
805 try:
806 isabs, = set(p[:1] == sep for d, p in drivesplits)
813 if len(set(d for d, p in drivesplits)) != 1:
837 try:
840 # This is overkill on Windows - just pass the path to GetFileAttributes