feat: Add html export to list command

This commit is contained in:
Cristian 2020-08-19 13:02:12 -05:00 committed by Cristian Vargas
parent aab8f96520
commit 885ff50449
6 changed files with 56 additions and 4 deletions

View file

@ -462,6 +462,7 @@ def printable_filesize(num_bytes: Union[int, float]) -> str:
@enforce_types
def printable_folders(folders: Dict[str, Optional["Link"]],
json: bool=False,
html: bool=False,
csv: Optional[str]=None,
index: bool=False) -> str:
links = folders.values()
@ -478,7 +479,14 @@ def printable_folders(folders: Dict[str, Optional["Link"]],
else:
output = links
return to_json(output, indent=4, sort_keys=True)
elif html:
from .index.html import main_index_template
if index:
output = main_index_template(links, True)
else:
from .index.html import MINIMAL_INDEX_TEMPLATE
output = main_index_template(links, True, MINIMAL_INDEX_TEMPLATE)
return output
elif csv:
from .index.csv import links_to_csv
return links_to_csv(folders.values(), cols=csv.split(','), header=True)