本文整理匯總了Python中zipimport._zip_directory_cache方法的典型用法代碼示例。如果您正苦於以下問題:Python zipimport._zip_directory_cache方法的具體用法?Python zipimport._zip_directory_cache怎麽用?Python zipimport._zip_directory_cache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類zipimport
的用法示例。
在下文中一共展示了zipimport._zip_directory_cache方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _remove_and_clear_zip_directory_cache_data
# 需要導入模塊: import zipimport [as 別名]
# 或者: from zipimport import _zip_directory_cache [as 別名]
def _remove_and_clear_zip_directory_cache_data(normalized_path):
def clear_and_remove_cached_zip_archive_directory_data(path, old_entry):
old_entry.clear()
_update_zipimporter_cache(
normalized_path, zipimport._zip_directory_cache,
updater=clear_and_remove_cached_zip_archive_directory_data)
# PyPy Python implementation does not allow directly writing to the
# zipimport._zip_directory_cache and so prevents us from attempting to correct
# its content. The best we can do there is clear the problematic cache content
# and have PyPy repopulate it as needed. The downside is that if there are any
# stale zipimport.zipimporter instances laying around, attempting to use them
# will fail due to not having its zip archive directory information available
# instead of being automatically corrected to use the new correct zip archive
# directory information.
示例2: _replace_zip_directory_cache_data
# 需要導入模塊: import zipimport [as 別名]
# 或者: from zipimport import _zip_directory_cache [as 別名]
def _replace_zip_directory_cache_data(normalized_path):
def replace_cached_zip_archive_directory_data(path, old_entry):
# N.B. In theory, we could load the zip directory information just
# once for all updated path spellings, and then copy it locally and
# update its contained path strings to contain the correct
# spelling, but that seems like a way too invasive move (this cache
# structure is not officially documented anywhere and could in
# theory change with new Python releases) for no significant
# benefit.
old_entry.clear()
zipimport.zipimporter(path)
old_entry.update(zipimport._zip_directory_cache[path])
return old_entry
_update_zipimporter_cache(
normalized_path, zipimport._zip_directory_cache,
updater=replace_cached_zip_archive_directory_data)
示例3: _remove_and_clear_zip_directory_cache_data
# 需要導入模塊: import zipimport [as 別名]
# 或者: from zipimport import _zip_directory_cache [as 別名]
def _remove_and_clear_zip_directory_cache_data(normalized_path):
def clear_and_remove_cached_zip_archive_directory_data(path, old_entry):
old_entry.clear()
_update_zipimporter_cache(
normalized_path, zipimport._zip_directory_cache,
updater=clear_and_remove_cached_zip_archive_directory_data)
# PyPy Python implementation does not allow directly writing to the
# zipimport._zip_directory_cache and so prevents us from attempting to correct
# its content. The best we can do there is clear the problematic cache content
# and have PyPy repopulate it as needed. The downside is that if there are any
# stale zipimport.zipimporter instances laying around, attempting to use them
# will fail due to not having its zip archive directory information available
# instead of being automatically corrected to use the new correct zip archive
# directory information.
示例4: uncache_zipdir
# 需要導入模塊: import zipimport [as 別名]
# 或者: from zipimport import _zip_directory_cache [as 別名]
def uncache_zipdir(path):
"""
Remove any globally cached zip file related data for `path`
Stale zipimport.zipimporter objects need to be removed when a zip file is
replaced as they contain cached zip file directory information. If they are
asked to get data from their zip file, they will use that cached
information to calculate the data location in the zip file. This calculated
location may be incorrect for the replaced zip file, which may in turn
cause the read operation to either fail or return incorrect data.
Note we have no way to clear any local caches from here. That is left up to
whomever is in charge of maintaining that cache.
"""
normalized_path = normalize_path(path)
_uncache(normalized_path, zipimport._zip_directory_cache)
_uncache(normalized_path, sys.path_importer_cache)