-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
37 lines (26 loc) · 904 Bytes
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
from datetime import datetime, timezone
from os import makedirs
from os.path import dirname, abspath, join, basename
from shlex import split
from shutil import rmtree
from subprocess import run
FORMAT = 'singlehtml'
sourcedir = dirname(abspath(__file__))
project_name = basename(sourcedir)
outputdir = join('/tmp/', project_name)
rmtree(outputdir, ignore_errors=True)
makedirs(outputdir, exist_ok=True)
run('clear')
cmd = split(f'sphinx-build -a -E -j auto --color -b {FORMAT} {sourcedir} {outputdir}')
run(cmd)
print('\n')
SECOND = 1
MINUTE = 60 * SECOND
last = run('git log -1 --format="%ad" --date=iso', shell=True, capture_output=True).stdout.strip().decode()
last = datetime.strptime(last, '%Y-%m-%d %H:%M:%S %z')
print('Last commit:', last)
delta = datetime.now(tz=timezone.utc) - last
min = delta.total_seconds() / MINUTE
min = round(min)
print(f'Since: {min}m')