当前位置: 首页>>代码示例>>Python>>正文


Python os2emxpath.isdir方法代码示例

本文整理汇总了Python中os2emxpath.isdir方法的典型用法代码示例。如果您正苦于以下问题:Python os2emxpath.isdir方法的具体用法?Python os2emxpath.isdir怎么用?Python os2emxpath.isdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在os2emxpath的用法示例。


在下文中一共展示了os2emxpath.isdir方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: makedirs

# 需要导入模块: import os2emxpath [as 别名]
# 或者: from os2emxpath import isdir [as 别名]
def makedirs(name, mode=0o777, exist_ok=False):
    """makedirs(path [, mode=0o777][, exist_ok=False])

    Super-mkdir; create a leaf directory and all intermediate ones.
    Works like mkdir, except that any intermediate path segment (not
    just the rightmost) will be created if it does not exist. If the
    target directory with the same mode as we specified already exists,
    raises an OSError if exist_ok is False, otherwise no exception is
    raised.  This is recursive.

    """
    head, tail = path.split(name)
    if not tail:
        head, tail = path.split(head)
    if head and tail and not path.exists(head):
        try:
            makedirs(head, mode, exist_ok)
        except OSError as e:
            # be happy if someone already created the path
            if e.errno != errno.EEXIST:
                raise
        cdir = curdir
        if isinstance(tail, bytes):
            cdir = bytes(curdir, 'ASCII')
        if tail == cdir:           # xxx/newdir/. exists if xxx/newdir exists
            return
    try:
        mkdir(name, mode)
    except OSError as e:
        dir_exists = path.isdir(name)
        expected_mode = _get_masked_mode(mode)
        if dir_exists:
            # S_ISGID is automatically copied by the OS from parent to child
            # directories on mkdir.  Don't consider it being set to be a mode
            # mismatch as mkdir does not unset it when not specified in mode.
            actual_mode = st.S_IMODE(lstat(name).st_mode) & ~st.S_ISGID
        else:
            actual_mode = -1
        if not (e.errno == errno.EEXIST and exist_ok and dir_exists and
                actual_mode == expected_mode):
            if dir_exists and actual_mode != expected_mode:
                e.strerror += ' (mode %o != expected mode %o)' % (
                        actual_mode, expected_mode)
            raise 
开发者ID:war-and-code,项目名称:jawfish,代码行数:46,代码来源:os.py


注:本文中的os2emxpath.isdir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。