diff options
author | Bernát Gábor <gaborjbernat@gmail.com> | 2022-07-25 00:33:42 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-25 00:33:42 -0700 |
commit | b85542c31ca8afcff317e618da434f59fa06d122 (patch) | |
tree | 450066fe494d366c03da70b0de10899d5738d425 /tasks/update_embedded.py | |
parent | 3c57468470c292b235a67b27cec9468cc913f268 (diff) | |
download | virtualenv-b85542c31ca8afcff317e618da434f59fa06d122.tar.gz |
Drop support of running under Python 2.7 (#2382)
Diffstat (limited to 'tasks/update_embedded.py')
-rwxr-xr-x | tasks/update_embedded.py | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/tasks/update_embedded.py b/tasks/update_embedded.py index 8144559..ba43b30 100755 --- a/tasks/update_embedded.py +++ b/tasks/update_embedded.py @@ -1,19 +1,10 @@ -#!/usr/bin/env python -""" -Helper script to rebuild virtualenv.py from virtualenv_support -""" -from __future__ import print_function, unicode_literals +"""Helper script to rebuild virtualenv.py from virtualenv_support""" import codecs import os import re -import sys from zlib import crc32 as _crc32 -if sys.version_info < (3,): - print("requires Python 3 (use tox from Python 3 if invoked via tox)") - raise SystemExit(1) - def crc32(data): """Python version idempotent""" @@ -31,7 +22,7 @@ file_template = '# file {filename}\n{variable} = convert(\n """\n{data}"""\n) def rebuild(script_path): - with open(script_path, "rt") as current_fh: + with open(script_path) as current_fh: script_content = current_fh.read() script_parts = [] match_end = 0 @@ -53,21 +44,21 @@ def rebuild(script_path): def handle_file(previous_content, filename, variable_name, previous_encoded): - print("Found file {}".format(filename)) + print(f"Found file {filename}") current_path = os.path.realpath(os.path.join(here, "..", "src", "virtualenv_embedded", filename)) _, file_type = os.path.splitext(current_path) keep_line_ending = file_type in (".bat",) - with open(current_path, "rt", encoding="utf-8", newline="" if keep_line_ending else None) as current_fh: + with open(current_path, encoding="utf-8", newline="" if keep_line_ending else None) as current_fh: current_text = current_fh.read() current_crc = crc32(current_text) current_encoded = b64.encode(gzip.encode(current_text.encode())[0])[0].decode() if current_encoded == previous_encoded: - print(" File up to date (crc: {:08x})".format(current_crc)) + print(f" File up to date (crc: {current_crc:08x})") return False, previous_content # Else: content has changed previous_text = gzip.decode(b64.decode(previous_encoded.encode())[0])[0].decode() previous_crc = crc32(previous_text) - print(" Content changed (crc: {:08x} -> {:08x})".format(previous_crc, current_crc)) + print(f" Content changed (crc: {previous_crc:08x} -> {current_crc:08x})") new_part = file_template.format(filename=filename, variable=variable_name, data=current_encoded) return True, new_part |