Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions remotezip.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from itertools import tee

import requests
from tabulate import tabulate

__all__ = ['RemoteIOError', 'RemoteZip']

Expand Down Expand Up @@ -259,12 +258,27 @@ def _list_files(url, support_suffix_range, filenames):
with RemoteZip(url, headers={'User-Agent': 'remotezip'}, support_suffix_range=support_suffix_range) as zip:
if len(filenames) == 0:
filenames = zip.namelist()
data = [('Length', 'DateTime', 'Name')]
data = []
for fname in filenames:
zinfo = zip.getinfo(fname)
dt = datetime(*zinfo.date_time)
data.append((zinfo.file_size, dt.strftime('%Y-%m-%d %H:%M:%S'), zinfo.filename))
print(tabulate(data, headers='firstrow'))
_printTable(data, ('Length', 'DateTime', 'Name'), '><<')


def _printTable(data, header, align):
# get max col width & prepare formatting string
col_w = [len(col) for col in header]
for row in data:
col_w = [max(w, len(str(x))) for w, x in zip(col_w, row)]
fmt = ' '.join('{{:{}{}}}'.format(a, w)
for w, a in zip(col_w, align + '<' * 99))
# print table
print(fmt.format(*header).rstrip())
print(fmt.format(*['-' * w for w in col_w]))
for row in data:
print(fmt.format(*row).rstrip())
print()


def _extract_files(url, support_suffix_range, filenames, path):
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='remotezip',
version='0.12.2',
version='0.12.3',
author='Giuseppe Tribulato',
author_email='[email protected]',
py_modules=['remotezip'],
Expand All @@ -14,7 +14,7 @@
description='Access zip file content hosted remotely without downloading the full file.',
long_description=description,
long_description_content_type="text/markdown",
install_requires=["requests", "tabulate"],
install_requires=["requests"],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you increase patch version above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

extras_require={
"test": ["requests_mock"],
},
Expand Down