Skip to content

Some tidy up for python 3 #1137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/apply_versions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
import os
import sys

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

Expand Down
8 changes: 5 additions & 3 deletions scripts/download_translations.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import sys
import json
import os
import sys
import time

import tolgee_requests

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


import glob, zipfile
import glob
import zipfile

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

Expand Down Expand Up @@ -113,7 +115,7 @@
print("Can't get translator list!")
langCredits[lang] = credits
percNum = a / c
perc = "{:.0%}".format(percNum)
perc = f"{percNum:.0%}"
if (perc == "100%" and percNum < 1):
perc = "99%"
if (perc == "100%" or lang == "en"):
Expand Down
13 changes: 7 additions & 6 deletions scripts/generate_excel_from_json.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import xlsxwriter
import os
import json
import os
import re
import subprocess

import xlsxwriter

root_dir = os.path.join(os.path.dirname(__file__), "..")
os.chdir(os.path.join(root_dir, "WebBasedData"))

Expand Down Expand Up @@ -121,9 +122,9 @@ def getChocolateyPackages() -> None:
input("PermissionError while deleting the old exe file.")
import sys
sys.exit(1)

workbook = xlsxwriter.Workbook('screenshot_database.xlsx', {'strings_to_urls': False})

worksheet = workbook.add_worksheet()

boldformat = workbook.add_format({"bold": True})
Expand Down Expand Up @@ -205,7 +206,7 @@ def getRow(n):
except KeyError:
pass
counter += 1

print("Generating Scoop packages...")

scoopCount = 0
Expand All @@ -228,7 +229,7 @@ def getRow(n):
pass
counter += 1

print("Generating Chocolatey packages...")
print("Generating Chocolatey packages...")

chocoCount = 0
chocoTotal = 0
Expand Down
8 changes: 4 additions & 4 deletions scripts/generate_integrity.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import sys
import json
import os
import glob
import hashlib
import json
import os
import sys
import time

root_dir = os.path.join(os.path.dirname(__file__), "..")
Expand All @@ -26,7 +26,7 @@
bytes = f.read() # read entire file as bytes
readable_hash = hashlib.sha256(bytes).hexdigest()
HASHES[file] = readable_hash

print(f"Elapsed {time.time()-time0} seconds")

parsed_dict = "HASHES: dict[str:str] = " + json.dumps(HASHES, indent=4)
Expand Down
11 changes: 7 additions & 4 deletions scripts/generate_json_from_excel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import os, xlrd, json
import json
import os
from urllib.request import urlopen

import xlrd

root_dir = os.path.join(os.path.dirname(__file__), "..")
os.chdir(os.path.join(root_dir, "WebBasedData"))

Expand All @@ -22,7 +25,7 @@
os.system("python -m pip install xlrd==1.2.0")
import xlrd
workbook = xlrd.open_workbook('screenshot_database.xlsx')

worksheet = workbook.sheet_by_index(0)

jsoncontent = {
Expand Down Expand Up @@ -53,7 +56,7 @@
assert (type(data[2]) == list)
if data[1] != "":
doneCount += 1

if not data[0] in jsoncontent["icons_and_screenshots"].keys():
jsoncontent["icons_and_screenshots"][data[0]] = {
"icon": data[1],
Expand All @@ -74,7 +77,7 @@

with open("screenshot-database-v2.json", "w") as outfile:
json.dump(jsoncontent, outfile, indent=4)



os.system("pause")
2 changes: 1 addition & 1 deletion scripts/get_contributors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
import json
import os

root_dir = os.path.join(os.path.dirname(__file__), "..")
os.chdir(root_dir) # move to root project
Expand Down
6 changes: 4 additions & 2 deletions scripts/purge_unusedtranslations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os, glob, json
import glob
import json
import os

try:
root_dir = os.path.join(os.path.dirname(__file__), "..")
Expand All @@ -25,5 +27,5 @@
print("Job finished succuessfully! 😎")
except Exception as e:
print("FAILED:", e)

os.system("pause")
3 changes: 2 additions & 1 deletion scripts/tolgee_requests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import json
import os

try:
import requests
except ImportError:
Expand Down
12 changes: 6 additions & 6 deletions scripts/translation_commands.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import argparse
import tolgee_requests
import translation_utils
import json
from time import sleep

import tolgee_requests
import translation_utils

__parser = argparse.ArgumentParser()
__group = __parser.add_mutually_exclusive_group(required=True)
Expand Down Expand Up @@ -41,7 +41,7 @@ def create(strs: list[str]):
count = len(strs)
i = 1
for key in strs:
print("[{num}/{count}] Key: {key}".format(num=i, count=count, key=encode_str(key, strip=100)))
print(f"[{i}/{count}] Key: {encode_str(key, strip=100)}")
i += 1
if not __args.yes and __confirm("Create?", ["y", "n"], "y") != "y":
continue
Expand All @@ -61,7 +61,7 @@ def delete(strs: list[str]):
count = len(strs)
i = 1
for key in strs:
print("[{num}/{count}] Key: {key}".format(num=i, count=count, key=encode_str(key, strip=100)))
print(f"[{i}/{count}] Key: {encode_str(key, strip=100)}")
i += 1
if not __args.yes and __confirm("Delete?", ["y", "n"], "y") != "y":
continue
Expand Down Expand Up @@ -91,7 +91,7 @@ def __delete(strs):
key_name = "not_used"
if key_name in strs:
stringsFound = len(strs[key_name])
print("Found not used strings: {count}".format(count=stringsFound))
print(f"Found not used strings: {stringsFound}")
if stringsFound > 0:
sleep(1)
delete(strs[key_name])
Expand All @@ -103,7 +103,7 @@ def __create(strs):
key_name = "not_translated"
if key_name in strs:
stringsFound = len(strs[key_name])
print("Found not translated strings: {count}".format(count=stringsFound))
print(f"Found not translated strings: {stringsFound}")
if stringsFound > 0:
if __args.print:
__print(strs[key_name])
Expand Down
4 changes: 2 additions & 2 deletions scripts/translation_utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import json
import os
import re
import json
import tolgee_requests

import tolgee_requests

root_dir = os.path.join(os.path.dirname(__file__), "..")
os.chdir(os.path.join(root_dir, "wingetui"))
Expand Down
Loading