Skip to content

Commit 5e7cf63

Browse files
committed
commit sha results
1 parent cd81dff commit 5e7cf63

File tree

4 files changed

+1098
-1094
lines changed

4 files changed

+1098
-1094
lines changed

src/check_sha.py

+14-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import requests
44
from tqdm import tqdm
55
from tools import get_whl_list
6-
from gen_whl import saved_sha256sums, save_sha256sums
6+
from gen_whl import get_saved_hash, save_sha
7+
8+
9+
saved_hash = get_saved_hash()
710

811

912
def get_sha_pkgs():
@@ -19,9 +22,10 @@ def get_sha_pkgs():
1922

2023

2124
def sha_check(filename: str, url: str, pbar: tqdm):
22-
if saved_sha256sums[filename]['verify']:
25+
if saved_hash[filename]['verify']:
26+
pbar.write(f'\r{filename} already verified!', end='')
2327
return True
24-
local_sha = saved_sha256sums[filename]['sha']
28+
local_sha = saved_hash[filename]['sha']
2529
remote_sha = url.split('#sha256=')[1]
2630
assert local_sha == remote_sha, f'{filename} sha256sum not match! local: {local_sha}, remote: {remote_sha}'
2731

@@ -36,25 +40,28 @@ def sha_check(filename: str, url: str, pbar: tqdm):
3640
f' cdn: {cdn_sha}\n'
3741
)
3842
else:
39-
saved_sha256sums[filename]['verify'] = True
43+
saved_hash[filename]['verify'] = True
44+
pbar.write(f'\r{filename} verified!', end='')
4045

4146

4247
def remove_obsolete():
4348
whl_list = get_whl_list()
4449
all_filenames = [pair[0] for pair in whl_list]
45-
for filename in saved_sha256sums.copy():
50+
for filename in saved_hash.copy():
4651
if filename not in all_filenames:
4752
logging.warning(f'{filename} not found in wheels.html!')
48-
saved_sha256sums.pop(filename)
53+
saved_hash.pop(filename)
4954

5055

5156
def main():
5257
pkgs = get_sha_pkgs()
5358
pbar = tqdm(pkgs)
59+
pbar.write('Checking sha256sum...')
5460
for pkg in pbar:
61+
pbar.set_description(pkg[0])
5562
sha_check(pkg[0], pkg[1], pbar)
5663
remove_obsolete()
57-
save_sha256sums()
64+
save_sha(saved_hash)
5865

5966

6067
if __name__ == '__main__':

src/gen_whl.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,24 @@ def get_local_whl_dict(d: list) -> dict:
1919
local_whl_dict = get_local_whl_dict([LINUX_WHEEL_DIR, WIN_WHEEL_DIR])
2020

2121

22-
def get_saved_sha256sums():
22+
def get_saved_hash():
2323
if os.path.exists(f'{whl_dir}/data/{sha_file}'):
2424
with open(f'{whl_dir}/data/{sha_file}', 'r', encoding='utf-8') as json_file:
2525
return json.load(json_file)
2626
return {}
2727

2828

29-
saved_sha256sums = get_saved_sha256sums()
29+
saved_hash = get_saved_hash()
3030

3131

3232
def get_whl_sha256(name: str):
33-
if name in saved_sha256sums:
34-
return saved_sha256sums[name]['sha']
33+
if name in saved_hash:
34+
return saved_hash[name]['sha']
3535
if name in local_whl_dict:
3636
path = local_whl_dict[name]
3737
with open(path, 'rb') as f:
3838
sha256sum = hashlib.sha256(f.read()).hexdigest()
39-
saved_sha256sums[name] = {'sha': sha256sum, 'verify': False}
39+
saved_hash[name] = {'sha': sha256sum, 'verify': False}
4040
return sha256sum
4141
return None
4242

@@ -130,15 +130,16 @@ def gen_html_cdn():
130130
html_file.write(html.replace('https://github.com/', 'https://gh.kmtea.eu/https://github.com/'))
131131

132132

133-
def save_sha256sums():
133+
def save_sha(sums: dict):
134+
sums = dict(sorted(sums.items(), key=lambda x: x[0].lower()))
134135
with open(f'{whl_dir}/data/{sha_file}', 'w', encoding='utf-8') as json_file:
135136
# for better git
136-
json.dump(saved_sha256sums, json_file, indent=2)
137+
json.dump(sums, json_file, indent=2)
137138

138139

139140
if __name__ == '__main__':
140141
if os.name == 'nt':
141142
gen_html()
142-
save_sha256sums()
143+
save_sha(saved_hash)
143144
else:
144145
gen_html_cdn()

src/tools.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import subprocess
77
from config import *
88
from tqdm import tqdm
9-
from gen_whl import saved_sha256sums
9+
from gen_whl import saved_hash
1010
from config_ver import PYTHON_TO_PYPY
1111

1212

@@ -57,7 +57,7 @@ def copy_wheels(dst: str):
5757
if file not in whl_html:
5858
new_whl.append((root, file))
5959
else:
60-
if file in saved_sha256sums:
60+
if file in saved_hash:
6161
logging.warning(f'Skip: \t{file} already exists in saved_sha256sums')
6262
else:
6363
new_whl.append((root, file))

0 commit comments

Comments
 (0)