本文整理匯總了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