src\wily\commands\index.py
-- -- --- --- --- --- --- --- ------- ------- ------- | """
-- -- --- --- --- --- --- --- ------- ------- ------- | Print command.
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- | Print information about the wily cache and what is in the index.
-- -- --- --- --- --- --- --- ------- ------- ------- | """
-- -- --- --- --- --- --- --- ------- ------- ------- | import tabulate
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- | from wily import MAX_MESSAGE_WIDTH, format_date, format_revision, logger
-- -- --- --- --- --- --- --- ------- ------- ------- | from wily.config.types import WilyConfig
-- -- --- --- --- --- --- --- ------- ------- ------- | from wily.helper import get_maxcolwidth, get_style
-- -- --- --- --- --- --- --- ------- ------- ------- | from wily.state import State
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | def index(
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | config: WilyConfig, include_message: bool = False, wrap: bool = False
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | ) -> None:
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | """
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | Show information about the cache and runtime.
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | :param config: The wily configuration
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | :param include_message: Include revision messages
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | :param wrap: Wrap long lines
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | """
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | state = State(config=config)
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | logger.debug("Running show command")
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | logger.info("--------Configuration---------")
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | logger.info(f"Path: {config.path}")
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | logger.info(f"Archiver: {config.archiver}")
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | logger.info(f"Operators: {config.operators}")
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | logger.info("")
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | logger.info("-----------History------------")
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | data = []
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | for archiver in state.archivers:
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | for rev in state.index[archiver].revisions:
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | if include_message:
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | data.append(
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | (
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | format_revision(rev.revision.key),
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | rev.revision.author_name,
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | rev.revision.message[:MAX_MESSAGE_WIDTH],
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | format_date(rev.revision.date),
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | )
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | )
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | else:
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | data.append(
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | (
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | format_revision(rev.revision.key),
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | rev.revision.author_name,
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | format_date(rev.revision.date),
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | )
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | )
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | if include_message:
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | headers = ("Revision", "Author", "Message", "Date")
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | else:
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | headers = ("Revision", "Author", "Date")
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | maxcolwidth = get_maxcolwidth(headers, wrap)
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | style = get_style()
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | print(
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | tabulate.tabulate(
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | headers=headers,
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | tabular_data=data,
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | tablefmt=style,
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | maxcolwidths=maxcolwidth,
-- 05 000 000 000 000 000 000 0000.00 0000.00 0000.00 | maxheadercolwidths=maxcolwidth,
-- -- 000 000 000 000 000 000 0000.00 0000.00 0000.00 | )
-- -- --- --- --- --- --- --- ------- ------- ------- | )