本文整理匯總了Python中stat.st_size方法的典型用法代碼示例。如果您正苦於以下問題:Python stat.st_size方法的具體用法?Python stat.st_size怎麽用?Python stat.st_size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類stat
的用法示例。
在下文中一共展示了stat.st_size方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _is_current
# 需要導入模塊: import stat [as 別名]
# 或者: from stat import st_size [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_size [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: _is_current
# 需要導入模塊: import stat [as 別名]
# 或者: from stat import st_size [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
示例4: _is_current
# 需要導入模塊: import stat [as 別名]
# 或者: from stat import st_size [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