1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/mangen.py

26 lines
687 B
Python
Raw Normal View History

2021-04-02 17:40:09 -07:00
#!/usr/bin/env python3
# Genereate man page from jc metadata using jinja2 templates
from datetime import date
2021-04-07 14:27:34 -07:00
import os
import gzip
import shutil
2021-04-02 17:40:09 -07:00
import jc.cli
from jinja2 import Environment, FileSystemLoader
file_loader = FileSystemLoader('templates')
2021-04-02 17:40:09 -07:00
env = Environment(loader=file_loader)
template = env.get_template('manpage_template')
2021-04-02 18:04:55 -07:00
output = template.render(today=date.today(),
jc=jc.cli.about_jc())
2021-04-02 17:40:09 -07:00
with open('man/jc.1', 'w') as f:
f.write(output)
2021-04-07 14:27:34 -07:00
with open('man/jc.1', 'rb') as f_in:
with gzip.open('man/jc.1.gz', 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)
shutil.copyfile('man/jc.1.gz', 'jc/man/jc.1.gz')
2021-04-07 14:27:34 -07:00
os.remove('man/jc.1')