forked from sanderland/katrain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile_version.py
59 lines (52 loc) · 2.32 KB
/
file_version.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# -*- mode: python ; coding: utf-8 -*-
from PyInstaller.utils.win32 import versioninfo as ver
import os
# only create VSVersionInfo object on Windows
versionInfo = None
if os.name == "nt":
# load constants.py to get version number and program name
import katrain.core.constants as constants
# build VSVersionInfo compatible version numbers
verParts = constants.VERSION.split(".")
numParts = len(verParts)
verList = list()
verString = ""
for i in range(4):
if i <= numParts - 1:
verList.append(int(verParts[i]))
verString = verString + verParts[i] + "."
else:
verList.append(int(0))
verString = verString + "0."
verString = verString.rstrip(".")
verTuple = tuple(verList)
versionInfo = ver.VSVersionInfo(
ffi=ver.FixedFileInfo(
filevers=verTuple, # must be 4 item tuple
prodvers=verTuple, # must be 4 item tuple
mask=0x3F, # Contains a bitmask that specifies the valid bits 'flags'r
flags=0x0, # Contains a bitmask that specifies the Boolean attributes of the file.
OS=0x40004, # The operating system for which this file was designed. 0x4 - NT and there is no need to change it.
fileType=0x1, # The general type of file. 0x1 - the file is an application.
subtype=0x0, # The function of the file. 0x0 - the function is not defined for this fileType
date=(0, 0), # Creation date and time stamp.
),
kids=[
ver.StringFileInfo(
[
ver.StringTable(
"040904B0",
[
ver.StringStruct("FileDescription", constants.PROGRAM_NAME),
ver.StringStruct("FileVersion", verString),
ver.StringStruct("LegalCopyright", constants.HOMEPAGE),
ver.StringStruct("OriginalFilename", constants.PROGRAM_NAME + ".exe"),
ver.StringStruct("ProductName", constants.PROGRAM_NAME),
ver.StringStruct("ProductVersion", verString),
],
)
]
),
ver.VarFileInfo([ver.VarStruct("Translation", [1033, 1200])]),
],
)