本文整理汇总了Python中sys.getPath函数的典型用法代码示例。如果您正苦于以下问题:Python getPath函数的具体用法?Python getPath怎么用?Python getPath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getPath函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exists
def exists(path):
"""Test whether a path exists.
Returns false for broken symbolic links.
"""
path = _tostr(path, "exists")
return File(sys.getPath(path)).exists()
示例2: getatime
def getatime(path):
# We can't detect access time so we return modification time. This
# matches the behaviour in os.stat().
path = _tostr(path, "getatime")
f = File(sys.getPath(path))
if not f.exists():
raise OSError(0, "No such file or directory", path)
return f.lastModified() / 1000.0
示例3: getsize
def getsize(path):
path = _tostr(path, "getsize")
f = File(sys.getPath(path))
size = f.length()
# Sadly, if the returned length is zero, we don't really know if the file
# is zero sized or does not exist.
if size == 0 and not f.exists():
raise OSError(0, "No such file or directory", path)
return size
示例4: mkdir
def mkdir(path, mode='ignored'):
"""mkdir(path [, mode=0777])
Create a directory.
The optional parameter is currently ignored.
"""
if not File(sys.getPath(path)).mkdir():
raise OSError(0, "couldn't make directory", path)
示例5: abspath
def abspath(path):
"""Return the absolute version of a path."""
try:
if isinstance(path, unicode):
if path:
path = sys.getPath(path)
else:
# Empty path must return current working directory
path = os.getcwdu()
else:
if path:
path = sys.getPath(path).encode('latin-1')
else:
# Empty path must return current working directory
path = os.getcwd()
except EnvironmentError:
pass # Bad path - return unchanged.
return normpath(path)
示例6: getmtime
def getmtime(path):
path = _tostr(path, "getmtime")
f = File(sys.getPath(path))
if not f.exists():
raise OSError(0, "No such file or directory", path)
return f.lastModified() / 1000.0
示例7: _realpath
def _realpath(path):
try:
return asPyString(File(sys.getPath(path)).getCanonicalPath())
except java.io.IOException:
return _abspath(path)
示例8: _abspath
def _abspath(path):
# Must use normpath separately because getAbsolutePath doesn't normalize
# and getCanonicalPath would eliminate symlinks.
return normpath(asPyString(File(sys.getPath(path)).getAbsolutePath()))
示例9: isdir
def isdir(path):
"""Test whether a path is a directory"""
path = _tostr(path, "isdir")
return File(sys.getPath(path)).isDirectory()
示例10: isfile
def isfile(path):
"""Test whether a path is a regular file"""
path = _tostr(path, "isfile")
return File(sys.getPath(path)).isFile()
示例11: rmdir
def rmdir(path):
"""rmdir(path)
Remove a directory."""
if not File(sys.getPath(path)).delete():
raise OSError(0, "couldn't delete directory", path)