本文整理汇总了Python中nt._getfullpathname方法的典型用法代码示例。如果您正苦于以下问题:Python nt._getfullpathname方法的具体用法?Python nt._getfullpathname怎么用?Python nt._getfullpathname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nt
的用法示例。
在下文中一共展示了nt._getfullpathname方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: absolute
# 需要导入模块: import nt [as 别名]
# 或者: from nt import _getfullpathname [as 别名]
def absolute(self):
"""Return an absolute version of this path. This function works
even if the path doesn't point to anything.
No normalization is done, i.e. all '.' and '..' will be kept along.
Use resolve() to get the canonical path to a file.
"""
# XXX untested yet!
if self._closed:
self._raise_closed()
if self.is_absolute():
return self
# FIXME this must defer to the specific flavour (and, under Windows,
# use nt._getfullpathname())
obj = self._from_parts([os.getcwd()] + self._parts, init=False)
obj._init(template=self)
return obj
示例2: abspath
# 需要导入模块: import nt [as 别名]
# 或者: from nt import _getfullpathname [as 别名]
def abspath(path):
"""Return the absolute version of a path."""
if path: # Empty path must return current working directory.
path = os.fspath(path)
try:
path = _getfullpathname(path)
except OSError:
pass # Bad path - return unchanged.
elif isinstance(path, bytes):
path = os.getcwdb()
else:
path = os.getcwd()
return normpath(path)
# realpath is a no-op on systems without islink support
示例3: test_deprecated
# 需要导入模块: import nt [as 别名]
# 或者: from nt import _getfullpathname [as 别名]
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)
示例4: _abspath_fallback
# 需要导入模块: import nt [as 别名]
# 或者: from nt import _getfullpathname [as 别名]
def _abspath_fallback(path):
"""Return the absolute version of a path as a fallback function in case
`nt._getfullpathname` is not available or raises OSError. See bpo-31047 for
more.
"""
path = os.fspath(path)
if not isabs(path):
if isinstance(path, bytes):
cwd = os.getcwdb()
else:
cwd = os.getcwd()
path = join(cwd, path)
return normpath(path)
# Return an absolute path.
示例5: abspath
# 需要导入模块: import nt [as 别名]
# 或者: from nt import _getfullpathname [as 别名]
def abspath(path):
"""Return the absolute version of a path."""
if path: # Empty path must return current working directory.
try:
path = _getfullpathname(path)
except WindowsError:
pass # Bad path - return unchanged.
elif isinstance(path, unicode):
path = os.getcwdu()
else:
path = os.getcwd()
return normpath(path)
# realpath is a no-op on systems without islink support
示例6: abspath
# 需要导入模块: import nt [as 别名]
# 或者: from nt import _getfullpathname [as 别名]
def abspath(path):
"""Return the absolute version of a path."""
if path: # Empty path must return current working directory.
try:
path = _getfullpathname(path)
except WindowsError:
pass # Bad path - return unchanged.
elif isinstance(path, _unicode):
path = os.getcwdu()
else:
path = os.getcwd()
return normpath(path)
# realpath is a no-op on systems without islink support
示例7: test__getfullpathname
# 需要导入模块: import nt [as 别名]
# 或者: from nt import _getfullpathname [as 别名]
def test__getfullpathname(self):
self.assertEqual(nt._getfullpathname('.'), nt.getcwd())
self.assertEqual(nt._getfullpathname('<bad>'), os.path.join(nt.getcwd(), '<bad>'))
self.assertEqual(nt._getfullpathname('bad:'), os.path.join(nt.getcwd(), 'bad:'))
self.assertEqual(nt._getfullpathname(':bad:'), os.path.join(nt.getcwd(), ':bad:'))
self.assertEqual(nt._getfullpathname('::'), '::\\')
self.assertEqual(nt._getfullpathname('1:'), '1:\\')
self.assertEqual(nt._getfullpathname('1:a'), '1:\\a')
self.assertEqual(nt._getfullpathname('1::'), '1:\\:')
self.assertEqual(nt._getfullpathname('1:\\'), '1:\\')
示例8: test__getfullpathname_neg
# 需要导入模块: import nt [as 别名]
# 或者: from nt import _getfullpathname [as 别名]
def test__getfullpathname_neg(self):
for bad in [None, 0, 34, -12345L, 3.14, object, self.test__getfullpathname]:
self.assertRaises(TypeError, nt._getfullpathname, bad)
示例9: abspath
# 需要导入模块: import nt [as 别名]
# 或者: from nt import _getfullpathname [as 别名]
def abspath(path):
"""Return the absolute version of a path."""
if path: # Empty path must return current working directory.
try:
path = _getfullpathname(path)
except OSError:
pass # Bad path - return unchanged.
elif isinstance(path, bytes):
path = os.getcwdb()
else:
path = os.getcwd()
return normpath(path)
# realpath is a no-op on systems without islink support