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


Python OSFS.getinfo方法代码示例

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


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

示例1: publish

# 需要导入模块: from fs.osfs import OSFS [as 别名]
# 或者: from fs.osfs.OSFS import getinfo [as 别名]
 def publish(self):
     super(PyFS, self).publish()
     deploy_fs = OSFS(self.site.config.deploy_root_path.path)
     for (dirnm, local_filenms) in deploy_fs.walk():
         logger.info("Making directory: %s", dirnm)
         self.fs.makedir(dirnm, allow_recreate=True)
         remote_fileinfos = self.fs.listdirinfo(dirnm, files_only=True)
         #  Process each local file, to see if it needs updating.
         for filenm in local_filenms:
             filepath = pathjoin(dirnm, filenm)
             #  Try to find an existing remote file, to compare metadata.
             for (nm, info) in remote_fileinfos:
                 if nm == filenm:
                     break
             else:
                 info = {}
             #  Skip it if the etags match
             if self.check_etag and "etag" in info:
                 with deploy_fs.open(filepath, "rb") as f:
                     local_etag = self._calculate_etag(f)
                 if info["etag"] == local_etag:
                     logger.info("Skipping file [etag]: %s", filepath)
                     continue
             #  Skip it if the mtime is more recent remotely.
             if self.check_mtime and "modified_time" in info:
                 local_mtime = deploy_fs.getinfo(filepath)["modified_time"]
                 if info["modified_time"] > local_mtime:
                     logger.info("Skipping file [mtime]: %s", filepath)
                     continue
             #  Upload it to the remote filesystem.
             logger.info("Uploading file: %s", filepath)
             with deploy_fs.open(filepath, "rb") as f:
                 self.fs.setcontents(filepath, f)
         #  Process each remote file, to see if it needs deleting.
         for (filenm, info) in remote_fileinfos:
             filepath = pathjoin(dirnm, filenm)
             if filenm not in local_filenms:
                 logger.info("Removing file: %s", filepath)
                 self.fs.remove(filepath)
开发者ID:jiivan,项目名称:hyde,代码行数:41,代码来源:pyfs.py


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