Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/win
diff options
context:
space:
mode:
authorlovetox <philipp@hoerist.com>2022-07-24 11:59:33 +0300
committerlovetox <philipp@hoerist.com>2022-07-24 11:59:33 +0300
commit81f3d555e74a5d673362664e4980a21b61537bcb (patch)
tree96bcd1e959e8b920b4e61bb6fb8d24dab505d863 /win
parent2242a9d8c55ede7387fc43a0e64906a0c9cb4ae6 (diff)
refactor: Use single quotes
Diffstat (limited to 'win')
-rw-r--r--win/misc/create-launcher.py76
1 files changed, 38 insertions, 38 deletions
diff --git a/win/misc/create-launcher.py b/win/misc/create-launcher.py
index d18ee19aa..f5e8d3225 100644
--- a/win/misc/create-launcher.py
+++ b/win/misc/create-launcher.py
@@ -7,10 +7,10 @@
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
-"""Creates simple Python .exe launchers for gui and cli apps
+# Creates simple Python .exe launchers for gui and cli apps
+#
+# ./create-launcher.py "1.4.0" <target-dir>
-./create-launcher.py "1.4.0" <target-dir>
-"""
import os
import sys
@@ -22,26 +22,26 @@ import struct
def build_resource(rc_path: str, out_path: str) -> None:
- """Raises subprocess.CalledProcessError"""
+ '''Raises subprocess.CalledProcessError'''
def is_64bit():
- return struct.calcsize("P") == 8
+ return struct.calcsize('P') == 8
subprocess.check_call(
- ["windres", "-O", "coff", "-F",
- "pe-x86-64" if is_64bit() else "pe-i386", rc_path,
- "-o", out_path])
+ ['windres', '-O', 'coff', '-F',
+ 'pe-x86-64' if is_64bit() else 'pe-i386', rc_path,
+ '-o', out_path])
def get_build_args() -> list[str]:
python_name = os.path.splitext(os.path.basename(sys.executable))[0]
python_config = os.path.join(
- os.path.dirname(sys.executable), python_name + "-config")
+ os.path.dirname(sys.executable), python_name + '-config')
cflags = subprocess.check_output(
- ["sh", python_config, "--cflags"]).strip()
+ ['sh', python_config, '--cflags']).strip()
libs = subprocess.check_output(
- ["sh", python_config, "--libs"]).strip()
+ ['sh', python_config, '--libs']).strip()
cflags = os.fsdecode(cflags)
libs = os.fsdecode(libs)
@@ -53,16 +53,16 @@ def build_exe(source_path: str,
is_gui: bool,
out_path: str) -> None:
- args = ["gcc", "-s"]
+ args = ['gcc', '-s']
if is_gui:
- args.append("-mwindows")
- args.extend(["-o", out_path, source_path, resource_path])
+ args.append('-mwindows')
+ args.extend(['-o', out_path, source_path, resource_path])
args.extend(get_build_args())
subprocess.check_call(args)
def get_launcher_code(debug: bool) -> str:
- template = """\
+ template = '''\
#include "Python.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -102,7 +102,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
Py_Finalize();
return result;
}
- """ % int(debug)
+ ''' % int(debug)
return template
@@ -115,7 +115,7 @@ def get_resouce_code(filename: str,
product_version: str,
company_name: str) -> str:
- template = """\
+ template = '''\
1 ICON "%(icon_path)s"
1 VERSIONINFO
FILEVERSION %(file_version_list)s
@@ -141,22 +141,22 @@ BEGIN
VALUE "Translation", 0x409, 1252
END
END
-"""
+'''
def to_ver_list(v: str) -> str:
- v = v.split("-")[0]
- return ",".join(map(str, (list(map(int, v.split("."))) + [0] * 4)[:4]))
+ v = v.split('-')[0]
+ return ','.join(map(str, (list(map(int, v.split('.'))) + [0] * 4)[:4]))
file_version_list = to_ver_list(file_version)
product_version_list = to_ver_list(product_version)
return template % {
- "icon_path": icon_path, "file_version_list": file_version_list,
- "product_version_list": product_version_list,
- "file_version": file_version, "product_version": product_version,
- "company_name": company_name, "filename": filename,
- "internal_name": os.path.splitext(filename)[0],
- "product_name": product_name, "file_desc": file_desc,
+ 'icon_path': icon_path, 'file_version_list': file_version_list,
+ 'product_version_list': product_version_list,
+ 'file_version': file_version, 'product_version': product_version,
+ 'company_name': company_name, 'filename': filename,
+ 'internal_name': os.path.splitext(filename)[0],
+ 'product_name': product_name, 'file_desc': file_desc,
}
@@ -178,16 +178,16 @@ def build_launcher(out_path: str,
temp = tempfile.mkdtemp()
try:
os.chdir(temp)
- with open("launcher.c", "w") as h:
+ with open('launcher.c', 'w') as h:
h.write(get_launcher_code(debug))
- shutil.copyfile(src_ico, "launcher.ico")
- with open("launcher.rc", "w") as h:
+ shutil.copyfile(src_ico, 'launcher.ico')
+ with open('launcher.rc', 'w') as h:
h.write(get_resouce_code(
os.path.basename(target), file_version, file_desc,
- "launcher.ico", product_name, product_version, company_name))
+ 'launcher.ico', product_name, product_version, company_name))
- build_resource("launcher.rc", "launcher.res")
- build_exe("launcher.c", "launcher.res", is_gui, target)
+ build_resource('launcher.rc', 'launcher.res')
+ build_exe('launcher.c', 'launcher.res', is_gui, target)
finally:
os.chdir(dir_)
shutil.rmtree(temp)
@@ -199,17 +199,17 @@ def main() -> None:
version = argv[1]
target = argv[2]
- company_name = "Gajim"
+ company_name = 'Gajim'
misc = os.path.dirname(os.path.realpath(__file__))
build_launcher(
- os.path.join(target, "Gajim.exe"),
- os.path.join(misc, "gajim.ico"), "Gajim", "Gajim",
+ os.path.join(target, 'Gajim.exe'),
+ os.path.join(misc, 'gajim.ico'), 'Gajim', 'Gajim',
version, company_name, True)
build_launcher(
- os.path.join(target, "Gajim-Debug.exe"),
- os.path.join(misc, "gajim.ico"), "Gajim", "Gajim",
+ os.path.join(target, 'Gajim-Debug.exe'),
+ os.path.join(misc, 'gajim.ico'), 'Gajim', 'Gajim',
version, company_name, False, debug=True)
# build_launcher(
@@ -218,5 +218,5 @@ def main() -> None:
# version, company_name, 'history_manager.py', True)
-if __name__ == "__main__":
+if __name__ == '__main__':
main()