gen_versioninfo.py: remove unused import, rename most variables and reformat

This commit is contained in:
bitraid 2018-04-22 20:35:34 +03:00
parent 8c16d81d89
commit 3f1041eb0a

View File

@ -20,49 +20,52 @@
"""Generate file_version_info.txt for Pyinstaller use with Windows builds.""" """Generate file_version_info.txt for Pyinstaller use with Windows builds."""
import os
import os.path import os.path
import sys import sys
from PyInstaller.utils.win32 import versioninfo from PyInstaller.utils.win32 import versioninfo as vs
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir, sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir,
os.pardir)) os.pardir))
import qutebrowser import qutebrowser
out_filename = 'file_version_info.txt' out_filename = 'file_version_info.txt'
FileVersion = qutebrowser.__version_info__ + (0,) filevers = qutebrowser.__version_info__ + (0,)
ProductVersion = qutebrowser.__version_info__ + (0,) prodvers = qutebrowser.__version_info__ + (0,)
str_filevers = qutebrowser.__version__
str_prodvers = qutebrowser.__version__
CommentText = "A keyboard-focused browser with a minimal GUI." comment_text = """\
CopyrightText = "© 2014-2018 Florian Bruhin (The Compiler) \ A keyboard-focused browser with a minimal GUI.\
<mail@qutebrowser.org>" """
TrademarkText = "qutebrowser is free software under the GNU General Public \ copyright_text = """\
License" © 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org>\
"""
trademark_text = """\
qutebrowser is free software under the GNU General Public License\
"""
FixedFileInfo = versioninfo.FixedFileInfo(FileVersion, ProductVersion) ffi = vs.FixedFileInfo(filevers, prodvers)
StringFileInfo = [versioninfo.StringFileInfo( kids = [vs.StringFileInfo(
[versioninfo.StringTable('040904B0', [vs.StringTable('040904B0',
[versioninfo.StringStruct('Comments',f'{CommentText}'), [vs.StringStruct('Comments', f'{comment_text}'),
versioninfo.StringStruct('CompanyName',"qutebrowser.org"), vs.StringStruct('CompanyName', "qutebrowser.org"),
versioninfo.StringStruct('FileDescription',"qutebrowser"), vs.StringStruct('FileDescription', "qutebrowser"),
versioninfo.StringStruct('FileVersion',f'{qutebrowser.__version__}'), vs.StringStruct('FileVersion', f'{str_filevers}'),
versioninfo.StringStruct('InternalName',"qutebrowser"), vs.StringStruct('InternalName', "qutebrowser"),
versioninfo.StringStruct('LegalCopyright',f'{CopyrightText}'), vs.StringStruct('LegalCopyright', f'{copyright_text}'),
versioninfo.StringStruct('LegalTrademarks',f'{TrademarkText}'), vs.StringStruct('LegalTrademarks', f'{trademark_text}'),
versioninfo.StringStruct('OriginalFilename',"qutebrowser.exe"), vs.StringStruct('OriginalFilename', "qutebrowser.exe"),
versioninfo.StringStruct('ProductName',"qutebrowser"), vs.StringStruct('ProductName', "qutebrowser"),
versioninfo.StringStruct('ProductVersion',f'{qutebrowser.__version__}')])]), vs.StringStruct('ProductVersion', f'{str_prodvers}')])]),
versioninfo.VarFileInfo([versioninfo.VarStruct('Translation', vs.VarFileInfo([vs.VarStruct('Translation', [1033, 1200])])]
[1033, 1200])])]
VSVersionInfo = versioninfo.VSVersionInfo(FixedFileInfo, StringFileInfo) file_version_info = vs.VSVersionInfo(ffi, kids)
with open(out_filename, 'w', encoding='utf-8') as f: with open(out_filename, 'w', encoding='utf-8') as f:
f.write(f'{VSVersionInfo}') f.write(f'{file_version_info}')
f.close() f.close()