本文整理匯總了Python中zipfile.getinfo方法的典型用法代碼示例。如果您正苦於以下問題:Python zipfile.getinfo方法的具體用法?Python zipfile.getinfo怎麽用?Python zipfile.getinfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類zipfile
的用法示例。
在下文中一共展示了zipfile.getinfo方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: PKzipSearch
# 需要導入模塊: import zipfile [as 別名]
# 或者: from zipfile import getinfo [as 別名]
def PKzipSearch(self, InvTABLEname, SQL, LOG, DLDir, savefile):
try:
# print(zipfile.getinfo(savefile))
if zipfile.is_zipfile(savefile):
file = zipfile.ZipFile(savefile, "r")
extracted_emails = []
for name in file.namelist():
if re.findall("php$", name):
scam_email2 = re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', str(file.read(name)))
for mailadd in scam_email2:
if mailadd not in extracted_emails:
extracted_emails.append(mailadd)
# Extracted scammers email
if any(map(len, extracted_emails)):
return [extracted_emails]
else:
LOG.info("No emails in this kit? Uglyyyyy ô0")
pass
else:
LOG.info("{} is not a zip file...".format(savefile))
except Exception as e:
print("[!!!] Problem with PKzipSearch Class: " + str(e))
示例2: __init__
# 需要導入模塊: import zipfile [as 別名]
# 或者: from zipfile import getinfo [as 別名]
def __init__(self, zipfile, entry=''):
"""
Create a new path pointer pointing at the specified entry
in the given zipfile.
:raise IOError: If the given zipfile does not exist, or if it
does not contain the specified entry.
"""
if isinstance(zipfile, string_types):
zipfile = OpenOnDemandZipFile(os.path.abspath(zipfile))
# Normalize the entry string, it should be relative:
entry = normalize_resource_name(entry, True, '/').lstrip('/')
# Check that the entry exists:
if entry:
try:
zipfile.getinfo(entry)
except Exception:
# Sometimes directories aren't explicitly listed in
# the zip file. So if `entry` is a directory name,
# then check if the zipfile contains any files that
# are under the given directory.
if (entry.endswith('/') and
[n for n in zipfile.namelist() if n.startswith(entry)]):
pass # zipfile contains a file in that directory.
else:
# Otherwise, complain.
raise IOError('Zipfile %r does not contain %r' %
(zipfile.filename, entry))
self._zipfile = zipfile
self._entry = entry
示例3: file_size
# 需要導入模塊: import zipfile [as 別名]
# 或者: from zipfile import getinfo [as 別名]
def file_size(self):
return self._zipfile.getinfo(self._entry).file_size
示例4: __init__
# 需要導入模塊: import zipfile [as 別名]
# 或者: from zipfile import getinfo [as 別名]
def __init__(self, zipfile, name):
info = zipfile.getinfo(name)
for x in dir(info):
if not (x.startswith("_") or x.endswith("_")):
setattr(self, x, getattr(info, x))
self.size = self.file_size
示例5: __init__
# 需要導入模塊: import zipfile [as 別名]
# 或者: from zipfile import getinfo [as 別名]
def __init__(self, zipfile, entry=''):
"""
Create a new path pointer pointing at the specified entry
in the given zipfile.
:raise IOError: If the given zipfile does not exist, or if it
does not contain the specified entry.
"""
if isinstance(zipfile, basestring):
zipfile = OpenOnDemandZipFile(os.path.abspath(zipfile))
# Normalize the entry string:
entry = re.sub('(^|/)/+', r'\1', entry)
# Check that the entry exists:
if entry:
try: zipfile.getinfo(entry)
except:
# Sometimes directories aren't explicitly listed in
# the zip file. So if `entry` is a directory name,
# then check if the zipfile contains any files that
# are under the given directory.
if (entry.endswith('/') and
[n for n in zipfile.namelist() if n.startswith(entry)]):
pass # zipfile contains a file in that directory.
else:
# Otherwise, complain.
raise IOError('Zipfile %r does not contain %r' %
(zipfile.filename, entry))
self._zipfile = zipfile
self._entry = entry
示例6: __init__
# 需要導入模塊: import zipfile [as 別名]
# 或者: from zipfile import getinfo [as 別名]
def __init__(self, zipfile, entry=''):
"""
Create a new path pointer pointing at the specified entry
in the given zipfile.
:raise IOError: If the given zipfile does not exist, or if it
does not contain the specified entry.
"""
if isinstance(zipfile, string_types):
zipfile = OpenOnDemandZipFile(os.path.abspath(zipfile))
# Check that the entry exists:
if entry:
# Normalize the entry string, it should be relative:
entry = normalize_resource_name(entry, True, '/').lstrip('/')
try:
zipfile.getinfo(entry)
except Exception:
# Sometimes directories aren't explicitly listed in
# the zip file. So if `entry` is a directory name,
# then check if the zipfile contains any files that
# are under the given directory.
if entry.endswith('/') and [
n for n in zipfile.namelist() if n.startswith(entry)
]:
pass # zipfile contains a file in that directory.
else:
# Otherwise, complain.
raise IOError(
'Zipfile %r does not contain %r' % (zipfile.filename, entry)
)
self._zipfile = zipfile
self._entry = entry