/
__init__.py
33 lines (29 loc) · 1019 Bytes
/
__init__.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
"""
mydata/__init__.py
This module updates mydata/commitdef.py to record the latest commit hash
for the About dialog in frozen platform-specific bundles.
"""
import distutils.spawn
import subprocess
import sys
__version__ = "0.7.3"
if hasattr(sys, "frozen"):
# pylint: disable=import-error
from .commitdef import LATEST_COMMIT
from .commitdef import LATEST_COMMIT_DATETIME
else:
LINE = None
with open(".git/logs/HEAD") as gitlog:
for LINE in gitlog:
pass
LATEST_COMMIT = LINE.split(" ")[1]
GIT = distutils.spawn.find_executable("git")
LATEST_COMMIT_DATETIME = subprocess.check_output(
[GIT, "log", "-1", "--pretty=format:%ci"])
with open("mydata/commitdef.py", 'w') as commitdef:
commitdef.write('"""\n')
commitdef.write('commitdef.py\n')
commitdef.write('"""\n')
commitdef.write('LATEST_COMMIT = "%s"\n' % LATEST_COMMIT)
commitdef.write(
'LATEST_COMMIT_DATETIME = "%s"\n' % LATEST_COMMIT_DATETIME)