我们从Python开源项目中,提取了以下22个代码示例,用于说明如何使用ntpath.isabs()。
def canonical_filename(self, filename): """Return a canonical filename for `filename`. An absolute path with no redundant components and normalized case. """ if filename not in self.canonical_filename_cache: if not os.path.isabs(filename): for path in [os.curdir] + sys.path: if path is None: continue f = os.path.join(path, filename) if os.path.exists(f): filename = f break cf = abs_file(filename) self.canonical_filename_cache[filename] = cf return self.canonical_filename_cache[filename]
def canonical_filename(filename): """Return a canonical file name for `filename`. An absolute path with no redundant components and normalized case. """ if filename not in CANONICAL_FILENAME_CACHE: if not os.path.isabs(filename): for path in [os.curdir] + sys.path: if path is None: continue f = os.path.join(path, filename) if os.path.exists(f): filename = f break cf = abs_file(filename) CANONICAL_FILENAME_CACHE[filename] = cf return CANONICAL_FILENAME_CACHE[filename]
def isabs_anywhere(filename): """Is `filename` an absolute path on any OS?""" return ntpath.isabs(filename) or posixpath.isabs(filename)
def test_isabs(self): tester('ntpath.isabs("c:\\")', 1) tester('ntpath.isabs("\\\\conky\\mountpoint\\")', 1) tester('ntpath.isabs("\\foo")', 1) tester('ntpath.isabs("\\foo\\bar")', 1)
def filename_is_same(win_path, local_path): import ntpath if ntpath.isabs(win_path) and path.isabs(local_path): return path.normcase(win_path) == path.normcase(local_path) return path.normcase(ntpath.basename(win_path)) == path.normcase(path.basename(local_path))
def __init__(self, path, filename): if filename and ntpath.isabs(filename): self.path, self.filename = ntpath.split(filename) else: self.filename = filename self.path = path