當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。