本文整理汇总了Python中twext.python.filepath.CachingFilePath.getsize方法的典型用法代码示例。如果您正苦于以下问题:Python CachingFilePath.getsize方法的具体用法?Python CachingFilePath.getsize怎么用?Python CachingFilePath.getsize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twext.python.filepath.CachingFilePath
的用法示例。
在下文中一共展示了CachingFilePath.getsize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: File
# 需要导入模块: from twext.python.filepath import CachingFilePath [as 别名]
# 或者: from twext.python.filepath.CachingFilePath import getsize [as 别名]
#.........这里部分代码省略.........
def etag(self):
if not self.fp.exists(): return succeed(None)
st = self.fp.statinfo
#
# Mark ETag as weak if it was modified more recently than we can
# measure and report, as it could be modified again in that span
# and we then wouldn't know to provide a new ETag.
#
weak = (time.time() - st.st_mtime <= 1)
return succeed(http_headers.ETag(
"%X-%X-%X" % (st.st_ino, st.st_size, st.st_mtime),
weak=weak
))
def lastModified(self):
if self.fp.exists():
return self.fp.getmtime()
else:
return None
def creationDate(self):
if self.fp.exists():
return self.fp.getmtime()
else:
return None
def contentLength(self):
if self.fp.exists():
if self.fp.isfile():
return self.fp.getsize()
else:
# Computing this would require rendering the resource; let's
# punt instead.
return None
else:
return None
def _initTypeAndEncoding(self):
self._type, self._encoding = getTypeAndEncoding(
self.fp.basename(),
self.contentTypes,
self.contentEncodings,
self.defaultType
)
# Handle cases not covered by getTypeAndEncoding()
if self.fp.isdir(): self._type = "httpd/unix-directory"
def contentType(self):
if not hasattr(self, "_type"):
self._initTypeAndEncoding()
return http_headers.MimeType.fromString(self._type)
def contentEncoding(self):
if not hasattr(self, "_encoding"):
self._initTypeAndEncoding()
return self._encoding
def displayName(self):
if self.fp.exists():
return self.fp.basename()
else: