本文整理汇总了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