summaryrefslogtreecommitdiff
path: root/Modules/_sha3/cleanup.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2014-01-03 14:05:06 +0100
committerMartin v. Löwis <martin@v.loewis.de>2014-01-03 14:05:06 +0100
commit24e43308b7e40c09717c1ab99014710fa5a01735 (patch)
treeb2a1198fbbb3e38ff6232785d474d6a0354a2648 /Modules/_sha3/cleanup.py
parentf3b46b4a66560945d4c80ac2f10764e3d7f71f8d (diff)
downloadcpython-git-24e43308b7e40c09717c1ab99014710fa5a01735.tar.gz
* Issue #16113: Remove sha3 module again.
Patch by Christian Heimes, with modifications.
Diffstat (limited to 'Modules/_sha3/cleanup.py')
-rwxr-xr-xModules/_sha3/cleanup.py49
1 files changed, 0 insertions, 49 deletions
diff --git a/Modules/_sha3/cleanup.py b/Modules/_sha3/cleanup.py
deleted file mode 100755
index aabcb0442c..0000000000
--- a/Modules/_sha3/cleanup.py
+++ /dev/null
@@ -1,49 +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("\ //(.*)")
-
-STATICS = ("void ", "int ", "HashReturn ", "const UINT64 ", "UINT16 ")
-
-HERE = os.path.dirname(os.path.abspath(__file__))
-KECCAK = os.path.join(HERE, "keccak")
-
-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 */", line)
- line = CPP2.sub(r" /* \1 */", 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)