diff options
author | Christian Heimes <christian@python.org> | 2022-03-26 20:36:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-26 20:36:08 (GMT) |
commit | 5fd8c574e016aec85725ddc5ced8742267b0e1b3 (patch) | |
tree | 04963f99f496dfc921de47fa0ce27a17d26de5ee /Modules/_sha3/cleanup.py | |
parent | b16b6bb8dacc41e9e569783890b0c88fcd3b24e8 (diff) | |
download | cpython-5fd8c574e016aec85725ddc5ced8742267b0e1b3.zip cpython-5fd8c574e016aec85725ddc5ced8742267b0e1b3.tar.gz cpython-5fd8c574e016aec85725ddc5ced8742267b0e1b3.tar.bz2 |
bpo-47098: Replace Keccak Code Package with tiny_sha3 (GH-32060)
Diffstat (limited to 'Modules/_sha3/cleanup.py')
-rwxr-xr-x | Modules/_sha3/cleanup.py | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/Modules/_sha3/cleanup.py b/Modules/_sha3/cleanup.py deleted file mode 100755 index 4f53681..0000000 --- a/Modules/_sha3/cleanup.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2012 Christian Heimes (christian@python.org) -# Licensed to PSF under a Contributor Agreement. -# -# cleanup Keccak sources - -import os -import re - -CPP1 = re.compile("^//(.*)") -CPP2 = re.compile(r"\ //(.*)") - -STATICS = ("void ", "int ", "HashReturn ", - "const UINT64 ", "UINT16 ", " int prefix##") - -HERE = os.path.dirname(os.path.abspath(__file__)) -KECCAK = os.path.join(HERE, "kcp") - -def getfiles(): - for name in os.listdir(KECCAK): - name = os.path.join(KECCAK, name) - if os.path.isfile(name): - yield name - -def cleanup(f): - buf = [] - for line in f: - # mark all functions and global data as static - #if line.startswith(STATICS): - # buf.append("static " + line) - # continue - # remove UINT64 typedef, we have our own - if line.startswith("typedef unsigned long long int"): - buf.append("/* %s */\n" % line.strip()) - continue - ## remove #include "brg_endian.h" - if "brg_endian.h" in line: - buf.append("/* %s */\n" % line.strip()) - continue - # transform C++ comments into ANSI C comments - line = CPP1.sub(r"/*\1 */\n", line) - line = CPP2.sub(r" /*\1 */\n", line) - buf.append(line) - return "".join(buf) - -for name in getfiles(): - with open(name) as f: - res = cleanup(f) - with open(name, "w") as f: - f.write(res) |