def log(self):
history = self.get_history()
outputs = []
for i, record in enumerate(history):
output = ''
record['timestamp'] = time.strftime(
'%a, %d %b %Y %H:%M:%S +0000',
time.strptime(record['updated'], '%Y%m%d-%H%M%S'))
checksum = (
' ({algorithm} {checksum})\nDate: {timestamp}'.format(
**record))
if self.versioned:
output = output + '\n' + (
click.style(
'version {}'.format(record['version']) + checksum,
fg='green'))
else:
output = output + '\n' + (
click.style(
'update {}'.format(len(history) - i) + checksum,
fg='green'))
for attr, val in sorted(record['user_config'].items()):
output = output + '\n' + (
'{:<10} {}'.format(attr+':', val))
if record.get('message', None) is not None:
wrapper = textwrap.TextWrapper(
initial_indent=' ',
subsequent_indent=' ',
width=66)
output = output + '\n\n'
output = output + '\n'.join(
wrapper.wrap(str(record['message'])))
outputs.append(output)
click.echo_via_pager('\n\n'.join(reversed(outputs)) + '\n')
评论列表
文章目录