本文整理汇总了Python中stat.st_mtime方法的典型用法代码示例。如果您正苦于以下问题:Python stat.st_mtime方法的具体用法?Python stat.st_mtime怎么用?Python stat.st_mtime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stat
的用法示例。
在下文中一共展示了stat.st_mtime方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _is_current
# 需要导入模块: import stat [as 别名]
# 或者: from stat import st_mtime [as 别名]
def _is_current(self, file_path, zip_path):
"""
Return True if the file_path is current for this zip_path
"""
timestamp, size = self._get_date_and_size(self.zipinfo[zip_path])
if not os.path.isfile(file_path):
return False
stat = os.stat(file_path)
if stat.st_size!=size or stat.st_mtime!=timestamp:
return False
# check that the contents match
zip_contents = self.loader.get_data(zip_path)
f = open(file_path, 'rb')
file_contents = f.read()
f.close()
return zip_contents == file_contents
示例2: get_file_sha256
# 需要导入模块: import stat [as 别名]
# 或者: from stat import st_mtime [as 别名]
def get_file_sha256(self, path:str) -> list:
"""
Checks if the file has a stored sha256 value
:param path:
:return: A list of sha256 strings
"""
stat = os.stat(path)
abspath = Path(path).resolve()
existing_entries = DataFile.select().where(
(
(DataFile.abspath == abspath) &
(DataFile.mtime == stat.st_mtime) &
(DataFile.size == stat.st_size)
)
)
sha256 = [e.sha256 for e in existing_entries]
return sha256
示例3: load
# 需要导入模块: import stat [as 别名]
# 或者: from stat import st_mtime [as 别名]
def load(self, path):
"""
Load a manifest at path or return a suitable manifest already loaded.
"""
path = os.path.normpath(path)
mtime = os.stat(path).st_mtime
if path not in self or self[path].mtime != mtime:
manifest = self.build(path)
self[path] = self.manifest_mod(manifest, mtime)
return self[path].manifest
示例4: _is_current
# 需要导入模块: import stat [as 别名]
# 或者: from stat import st_mtime [as 别名]
def _is_current(self, file_path, zip_path):
"""
Return True if the file_path is current for this zip_path
"""
timestamp, size = self._get_date_and_size(self.zipinfo[zip_path])
if not os.path.isfile(file_path):
return False
stat = os.stat(file_path)
if stat.st_size != size or stat.st_mtime != timestamp:
return False
# check that the contents match
zip_contents = self.loader.get_data(zip_path)
with open(file_path, 'rb') as f:
file_contents = f.read()
return zip_contents == file_contents
示例5: _is_current
# 需要导入模块: import stat [as 别名]
# 或者: from stat import st_mtime [as 别名]
def _is_current(self, file_path, zip_path):
"""
Return True if the file_path is current for this zip_path
"""
timestamp, size = self._get_date_and_size(self.zipinfo[zip_path])
if not os.path.isfile(file_path):
return False
stat = os.stat(file_path)
if stat.st_size!=size or stat.st_mtime!=timestamp:
return False
# check that the contents match
zip_contents = self.loader.get_data(zip_path)
with open(file_path, 'rb') as f:
file_contents = f.read()
return zip_contents == file_contents