Skip to content

Commit 6679419

Browse files
authored
Merge pull request #1137 from marksmayo/main
Some tidy up for python 3
2 parents 9afb9f3 + bd6a27e commit 6679419

31 files changed

+773
-703
lines changed

scripts/apply_versions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import sys
21
import os
2+
import sys
33

44
os.chdir(os.path.join(os.path.dirname(__file__), "..")) # move to root project
55

scripts/download_translations.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import sys
21
import json
32
import os
3+
import sys
44
import time
5+
56
import tolgee_requests
67

78
root_dir = os.path.join(os.path.dirname(__file__), "..")
@@ -27,7 +28,8 @@
2728
print(sys.argv[1])
2829

2930

30-
import glob, zipfile
31+
import glob
32+
import zipfile
3133

3234
os.chdir(os.path.normpath(os.path.join(root_dir, "wingetui/lang")))
3335

@@ -113,7 +115,7 @@
113115
print("Can't get translator list!")
114116
langCredits[lang] = credits
115117
percNum = a / c
116-
perc = "{:.0%}".format(percNum)
118+
perc = f"{percNum:.0%}"
117119
if (perc == "100%" and percNum < 1):
118120
perc = "99%"
119121
if (perc == "100%" or lang == "en"):

scripts/generate_excel_from_json.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import xlsxwriter
2-
import os
31
import json
2+
import os
43
import re
54
import subprocess
65

6+
import xlsxwriter
7+
78
root_dir = os.path.join(os.path.dirname(__file__), "..")
89
os.chdir(os.path.join(root_dir, "WebBasedData"))
910

@@ -121,9 +122,9 @@ def getChocolateyPackages() -> None:
121122
input("PermissionError while deleting the old exe file.")
122123
import sys
123124
sys.exit(1)
124-
125+
125126
workbook = xlsxwriter.Workbook('screenshot_database.xlsx', {'strings_to_urls': False})
126-
127+
127128
worksheet = workbook.add_worksheet()
128129

129130
boldformat = workbook.add_format({"bold": True})
@@ -205,7 +206,7 @@ def getRow(n):
205206
except KeyError:
206207
pass
207208
counter += 1
208-
209+
209210
print("Generating Scoop packages...")
210211

211212
scoopCount = 0
@@ -228,7 +229,7 @@ def getRow(n):
228229
pass
229230
counter += 1
230231

231-
print("Generating Chocolatey packages...")
232+
print("Generating Chocolatey packages...")
232233

233234
chocoCount = 0
234235
chocoTotal = 0

scripts/generate_integrity.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import sys
2-
import json
3-
import os
41
import glob
52
import hashlib
3+
import json
4+
import os
5+
import sys
66
import time
77

88
root_dir = os.path.join(os.path.dirname(__file__), "..")
@@ -26,7 +26,7 @@
2626
bytes = f.read() # read entire file as bytes
2727
readable_hash = hashlib.sha256(bytes).hexdigest()
2828
HASHES[file] = readable_hash
29-
29+
3030
print(f"Elapsed {time.time()-time0} seconds")
3131

3232
parsed_dict = "HASHES: dict[str:str] = " + json.dumps(HASHES, indent=4)

scripts/generate_json_from_excel.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
import os, xlrd, json
1+
import json
2+
import os
23
from urllib.request import urlopen
34

5+
import xlrd
6+
47
root_dir = os.path.join(os.path.dirname(__file__), "..")
58
os.chdir(os.path.join(root_dir, "WebBasedData"))
69

@@ -22,7 +25,7 @@
2225
os.system("python -m pip install xlrd==1.2.0")
2326
import xlrd
2427
workbook = xlrd.open_workbook('screenshot_database.xlsx')
25-
28+
2629
worksheet = workbook.sheet_by_index(0)
2730

2831
jsoncontent = {
@@ -53,7 +56,7 @@
5356
assert (type(data[2]) == list)
5457
if data[1] != "":
5558
doneCount += 1
56-
59+
5760
if not data[0] in jsoncontent["icons_and_screenshots"].keys():
5861
jsoncontent["icons_and_screenshots"][data[0]] = {
5962
"icon": data[1],
@@ -74,7 +77,7 @@
7477

7578
with open("screenshot-database-v2.json", "w") as outfile:
7679
json.dump(jsoncontent, outfile, indent=4)
77-
80+
7881

7982

8083
os.system("pause")

scripts/get_contributors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import os
21
import json
2+
import os
33

44
root_dir = os.path.join(os.path.dirname(__file__), "..")
55
os.chdir(root_dir) # move to root project

scripts/purge_unusedtranslations.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import os, glob, json
1+
import glob
2+
import json
3+
import os
24

35
try:
46
root_dir = os.path.join(os.path.dirname(__file__), "..")
@@ -25,5 +27,5 @@
2527
print("Job finished succuessfully! 😎")
2628
except Exception as e:
2729
print("FAILED:", e)
28-
30+
2931
os.system("pause")

scripts/tolgee_requests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import os
21
import json
2+
import os
3+
34
try:
45
import requests
56
except ImportError:

scripts/translation_commands.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import argparse
2-
import tolgee_requests
3-
import translation_utils
42
import json
53
from time import sleep
64

5+
import tolgee_requests
6+
import translation_utils
77

88
__parser = argparse.ArgumentParser()
99
__group = __parser.add_mutually_exclusive_group(required=True)
@@ -41,7 +41,7 @@ def create(strs: list[str]):
4141
count = len(strs)
4242
i = 1
4343
for key in strs:
44-
print("[{num}/{count}] Key: {key}".format(num=i, count=count, key=encode_str(key, strip=100)))
44+
print(f"[{i}/{count}] Key: {encode_str(key, strip=100)}")
4545
i += 1
4646
if not __args.yes and __confirm("Create?", ["y", "n"], "y") != "y":
4747
continue
@@ -61,7 +61,7 @@ def delete(strs: list[str]):
6161
count = len(strs)
6262
i = 1
6363
for key in strs:
64-
print("[{num}/{count}] Key: {key}".format(num=i, count=count, key=encode_str(key, strip=100)))
64+
print(f"[{i}/{count}] Key: {encode_str(key, strip=100)}")
6565
i += 1
6666
if not __args.yes and __confirm("Delete?", ["y", "n"], "y") != "y":
6767
continue
@@ -91,7 +91,7 @@ def __delete(strs):
9191
key_name = "not_used"
9292
if key_name in strs:
9393
stringsFound = len(strs[key_name])
94-
print("Found not used strings: {count}".format(count=stringsFound))
94+
print(f"Found not used strings: {stringsFound}")
9595
if stringsFound > 0:
9696
sleep(1)
9797
delete(strs[key_name])
@@ -103,7 +103,7 @@ def __create(strs):
103103
key_name = "not_translated"
104104
if key_name in strs:
105105
stringsFound = len(strs[key_name])
106-
print("Found not translated strings: {count}".format(count=stringsFound))
106+
print(f"Found not translated strings: {stringsFound}")
107107
if stringsFound > 0:
108108
if __args.print:
109109
__print(strs[key_name])

scripts/translation_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import json
12
import os
23
import re
3-
import json
4-
import tolgee_requests
54

5+
import tolgee_requests
66

77
root_dir = os.path.join(os.path.dirname(__file__), "..")
88
os.chdir(os.path.join(root_dir, "wingetui"))

0 commit comments

Comments
 (0)