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


Python Path.getcwd方法代码示例

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


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

示例1: f

# 需要导入模块: from fbuild.path import Path [as 别名]
# 或者: from fbuild.path.Path import getcwd [as 别名]
        def f(module, include):
            # On case-insensitive but case-preserving filesystems, we need to
            # be careful on how we deal with finding OCaml dependencies. Since
            # OCaml can store a module named List in either list.ml or List.ml,
            # we can't just test if the filename exists since fbuild needs to
            # deal with the exact filenames.  To do that, we'll grab the list
            # of filenames in the directory, then search for the right
            # spelling in that list.

            # Grab the filenames in the directory.
            if include is None:
                dirs = Path.getcwd().listdir()
            else:
                include = Path(include)

                if not include.exists():
                    # We can't search for dependencies in a directory that
                    # doesn't exist, so exit early.
                    return False

                dirs = include.listdir()

            found = False
            for suffix in '.mli', '.ml':
                # Look for the traditional lowercase form.
                path = module[0].lower() + module[1:] + suffix
                if path not in dirs:
                    # That didn't work, so lets try the uppercase form.
                    path = module[0].upper() + module[1:] + suffix
                    if path not in dirs:
                        # Couldn't find it, so just skip this module.
                        continue

                # We found it! Add that file to the dependencies.
                if include is None:
                    deps.append(Path(path))
                else:
                    deps.append(include / path)
                found = True

            return found
开发者ID:ACGCross,项目名称:felix,代码行数:43,代码来源:__init__.py


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