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


Python Folder.file_or_folder方法代码示例

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


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

示例1: translate_path

# 需要导入模块: from fswrap import Folder [as 别名]
# 或者: from fswrap.Folder import file_or_folder [as 别名]
    def translate_path(self, path):
        """
        Finds the absolute path of the requested file by
        referring to the `site` variable in the server.
        """
        site = self.server.site
        result = urlparse.urlparse(urllib.unquote(self.path).decode("utf-8"))
        logger.debug("Trying to load file based on request: [%s]" % result.path)
        path = result.path.lstrip("/")
        res = None
        if path.strip() == "" or File(path).kind.strip() == "":
            deployed = site.config.deploy_root_path.child(path)
            deployed = Folder.file_or_folder(deployed)
            if isinstance(deployed, Folder):
                node = site.content.node_from_relative_path(path)
                res = node.get_resource("index.html")
            elif hasattr(site.config, "urlcleaner") and hasattr(site.config.urlcleaner, "strip_extensions"):
                for ext in site.config.urlcleaner.strip_extensions:
                    res = site.content.resource_from_relative_deploy_path(path + "." + ext)
                    if res:
                        break
                for ext in site.config.urlcleaner.strip_extensions:
                    new_path = site.config.deploy_root_path.child(path + "." + ext)
                    if File(new_path).exists:
                        return new_path
        else:
            res = site.content.resource_from_relative_deploy_path(path)

        if not res:
            logger.error("Cannot load file: [%s]" % path)
            return site.config.deploy_root_path.child(path)
        else:
            self.server.generate_resource(res)
        new_path = site.config.deploy_root_path.child(res.relative_deploy_path)
        return new_path
开发者ID:JeNeSuisPasDave,项目名称:hyde,代码行数:37,代码来源:server.py

示例2: maker

# 需要导入模块: from fswrap import Folder [as 别名]
# 或者: from fswrap.Folder import file_or_folder [as 别名]
 def maker(source, target):
     stuff = ['apps', 'lib', 'app.js', 'package.json']
     for f in stuff:
         fs = Folder.file_or_folder(source.child(f))
         fs.copy_to(target)
开发者ID:gitbot,项目名称:builder,代码行数:7,代码来源:builder.py


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