59 lines
1.0 KiB
Python
59 lines
1.0 KiB
Python
import argparse
|
|
import logging
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
from personal_data.csv_import import load_csv_file
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def parse_arguments():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument(
|
|
'file',
|
|
type=Path,
|
|
)
|
|
parser.add_argument(
|
|
'output_file',
|
|
type=Path,
|
|
)
|
|
|
|
return parser.parse_args()
|
|
|
|
|
|
def format_data_to_html(data: list[dict[str, Any]], mode: str = 'latest') -> str:
|
|
sample = data[-1]
|
|
|
|
l = []
|
|
l.append('<html>')
|
|
l.append('<body>')
|
|
|
|
for k, v in sample.items():
|
|
l.append(f'<div><b>{k}</b>: {v}</div>')
|
|
|
|
l.append('</body>')
|
|
l.append('</html>')
|
|
|
|
return ''.join(l)
|
|
|
|
|
|
def main():
|
|
logging.basicConfig()
|
|
logging.getLogger('git_time_tracker').setLevel('INFO')
|
|
|
|
args = parse_arguments()
|
|
|
|
# Load data
|
|
data = load_csv_file(args.file)
|
|
print(data)
|
|
|
|
html = format_data_to_html(data)
|
|
|
|
with open(args.output_file, 'w') as f:
|
|
f.write(html)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|