mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
scripted-diff: use PEP 585 built-in collection types for verify-binary script
-BEGIN VERIFY SCRIPT- sed -i 's|t\.Dict|dict|g' ./contrib/verify-binaries/verify.py sed -i 's|t\.List|list|g' ./contrib/verify-binaries/verify.py sed -i 's|t\.Tuple|tuple|g' ./contrib/verify-binaries/verify.py -END VERIFY SCRIPT-
This commit is contained in:
parent
d516cf83ed
commit
4b9afb18e6
1 changed files with 13 additions and 13 deletions
|
@ -122,7 +122,7 @@ def download_with_wget(remote_file, local_file):
|
|||
return result.returncode == 0, result.stdout.decode().rstrip()
|
||||
|
||||
|
||||
def download_lines_with_urllib(url) -> t.Tuple[bool, t.List[str]]:
|
||||
def download_lines_with_urllib(url) -> tuple[bool, list[str]]:
|
||||
"""Get (success, text lines of a file) over HTTP."""
|
||||
try:
|
||||
return (True, [
|
||||
|
@ -138,7 +138,7 @@ def verify_with_gpg(
|
|||
filename,
|
||||
signature_filename,
|
||||
output_filename: t.Optional[str] = None
|
||||
) -> t.Tuple[int, str]:
|
||||
) -> tuple[int, str]:
|
||||
with tempfile.NamedTemporaryFile() as status_file:
|
||||
args = [
|
||||
'gpg', '--yes', '--verify', '--verify-options', 'show-primary-uid-only', "--status-file", status_file.name,
|
||||
|
@ -177,12 +177,12 @@ class SigData:
|
|||
|
||||
|
||||
def parse_gpg_result(
|
||||
output: t.List[str]
|
||||
) -> t.Tuple[t.List[SigData], t.List[SigData], t.List[SigData]]:
|
||||
output: list[str]
|
||||
) -> tuple[list[SigData], list[SigData], list[SigData]]:
|
||||
"""Returns good, unknown, and bad signatures from GPG stdout."""
|
||||
good_sigs: t.List[SigData] = []
|
||||
unknown_sigs: t.List[SigData] = []
|
||||
bad_sigs: t.List[SigData] = []
|
||||
good_sigs: list[SigData] = []
|
||||
unknown_sigs: list[SigData] = []
|
||||
bad_sigs: list[SigData] = []
|
||||
total_resolved_sigs = 0
|
||||
|
||||
# Ensure that all lines we match on include a prefix that prevents malicious input
|
||||
|
@ -265,7 +265,7 @@ def files_are_equal(filename1, filename2):
|
|||
|
||||
|
||||
def get_files_from_hosts_and_compare(
|
||||
hosts: t.List[str], path: str, filename: str, require_all: bool = False
|
||||
hosts: list[str], path: str, filename: str, require_all: bool = False
|
||||
) -> ReturnCode:
|
||||
"""
|
||||
Retrieve the same file from a number of hosts and ensure they have the same contents.
|
||||
|
@ -326,7 +326,7 @@ def get_files_from_hosts_and_compare(
|
|||
return ReturnCode.SUCCESS
|
||||
|
||||
|
||||
def check_multisig(sums_file: str, sigfilename: str, args: argparse.Namespace) -> t.Tuple[int, str, t.List[SigData], t.List[SigData], t.List[SigData]]:
|
||||
def check_multisig(sums_file: str, sigfilename: str, args: argparse.Namespace) -> tuple[int, str, list[SigData], list[SigData], list[SigData]]:
|
||||
# check signature
|
||||
#
|
||||
# We don't write output to a file because this command will almost certainly
|
||||
|
@ -365,8 +365,8 @@ def prompt_yn(prompt) -> bool:
|
|||
|
||||
def verify_shasums_signature(
|
||||
signature_file_path: str, sums_file_path: str, args: argparse.Namespace
|
||||
) -> t.Tuple[
|
||||
ReturnCode, t.List[SigData], t.List[SigData], t.List[SigData], t.List[SigData]
|
||||
) -> tuple[
|
||||
ReturnCode, list[SigData], list[SigData], list[SigData], list[SigData]
|
||||
]:
|
||||
min_good_sigs = args.min_good_sigs
|
||||
gpg_allowed_codes = [0, 2] # 2 is returned when untrusted signatures are present.
|
||||
|
@ -429,14 +429,14 @@ def verify_shasums_signature(
|
|||
return (ReturnCode.SUCCESS, good_trusted, good_untrusted, unknown, bad)
|
||||
|
||||
|
||||
def parse_sums_file(sums_file_path: str, filename_filter: t.List[str]) -> t.List[t.List[str]]:
|
||||
def parse_sums_file(sums_file_path: str, filename_filter: list[str]) -> list[list[str]]:
|
||||
# extract hashes/filenames of binaries to verify from hash file;
|
||||
# each line has the following format: "<hash> <binary_filename>"
|
||||
with open(sums_file_path, 'r', encoding='utf8') as hash_file:
|
||||
return [line.split()[:2] for line in hash_file if len(filename_filter) == 0 or any(f in line for f in filename_filter)]
|
||||
|
||||
|
||||
def verify_binary_hashes(hashes_to_verify: t.List[t.List[str]]) -> t.Tuple[ReturnCode, t.Dict[str, str]]:
|
||||
def verify_binary_hashes(hashes_to_verify: list[list[str]]) -> tuple[ReturnCode, dict[str, str]]:
|
||||
offending_files = []
|
||||
files_to_hashes = {}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue