FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpython/Modules/_sha3/cleanup.py at pythoncapi · pythoncapi/cpython · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
pythoncapi
/
cpython
Public
forked from
python/cpython
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpython
/
Modules
/
_sha3
/
cleanup.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
50 lines (43 loc) · 1.41 KB
Breadcrumbs
cpython
/
Modules
/
_sha3
/
cleanup.py
Copy path
File metadata and controls
executable file
·
50 lines (43 loc) · 1.41 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/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 "
,
" 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
)
Back
|
FazBrowse Home
|
New Git URL