我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用nt._isdir()。
def test_deprecated(self): import nt filename = os.fsencode(support.TESTFN) with warnings.catch_warnings(): warnings.simplefilter("error", DeprecationWarning) for func, *args in ( (nt._getfullpathname, filename), (nt._isdir, filename), (os.access, filename, os.R_OK), (os.chdir, filename), (os.chmod, filename, 0o777), (os.getcwdb,), (os.link, filename, filename), (os.listdir, filename), (os.lstat, filename), (os.mkdir, filename), (os.open, filename, os.O_RDONLY), (os.rename, filename, filename), (os.rmdir, filename), (os.startfile, filename), (os.stat, filename), (os.unlink, filename), (os.utime, filename), ): self.assertRaises(DeprecationWarning, func, *args)
def walk(top, func, arg): """Directory tree walk with callback function. For each directory in the directory tree rooted at top (including top itself, but excluding '.' and '..'), call func(arg, dirname, fnames). dirname is the name of the directory, and fnames a list of the names of the files and subdirectories in dirname (excluding '.' and '..'). func may modify the fnames list in-place (e.g. via del or slice assignment), and walk will only recurse into the subdirectories whose names remain in fnames; this can be used to implement a filter, or to impose a specific order of visiting. No semantics are defined for, or required of, arg, beyond that arg is always passed to func. It can be used, e.g., to pass a filename pattern, or a mutable object designed to accumulate statistics. Passing None for arg is common.""" warnings.warnpy3k("In 3.x, os.path.walk is removed in favor of os.walk.", stacklevel=2) try: names = os.listdir(top) except os.error: return func(arg, top, names) for name in names: name = join(top, name) if isdir(name): walk(name, func, arg) # Expand paths beginning with '~' or '~user'. # '~' means $HOME; '~user' means that user's home directory. # If the path doesn't begin with '~', or if the user or $HOME is unknown, # the path is returned unchanged (leaving error reporting to whatever # function is called with the expanded path as argument). # See also module 'glob' for expansion of *, ? and [...] in pathnames. # (A function should also be defined to do full *sh-style environment # variable expansion.)