46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
import sys
|
|
from argparse import ArgumentParser
|
|
|
|
from dump_things_service.audit.gitaudit import GitAuditBackend
|
|
|
|
|
|
parser = ArgumentParser(
|
|
prog='Report audit information for a PID',
|
|
description='Report the audit information that was stored for a specific '
|
|
'PID. For every change to a record the tool will report: '
|
|
'time stamp, user ID, diff, and the resulting record.',
|
|
)
|
|
parser.add_argument(
|
|
'audit_store',
|
|
help='The path to the gitaudit store',
|
|
)
|
|
parser.add_argument(
|
|
'pid',
|
|
help='The PID of the record for which audit information should be reported.',
|
|
)
|
|
|
|
|
|
def main():
|
|
arguments = parser.parse_args()
|
|
|
|
audit_backend = GitAuditBackend(arguments.audit_store)
|
|
changes = audit_backend.get_audit_log(arguments.pid)
|
|
|
|
output = {
|
|
time_stamp: {
|
|
'user-id': change[0],
|
|
'diff': change[1],
|
|
'resulting-record': change[2],
|
|
}
|
|
for time_stamp, change in changes.items()
|
|
}
|
|
|
|
print(json.dumps(output, indent=2, ensure_ascii=False))
|
|
return 0
|
|
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main())
|