Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_base
Commits
65412f45
Commit
65412f45
authored
Mar 28, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update script
parent
6739c7b1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
23 deletions
+15
-23
script/garble/insert.py
+15
-23
No files found.
script/garble/insert.py
View file @
65412f45
...
...
@@ -7,12 +7,13 @@ import glob, os
used_names
=
[]
activity_mangle_setting
=
{}
# rand string for class names
def
gen_rand_str
():
rand_str
=
''
.
join
(
random
.
choices
(
string
.
ascii_uppercase
+
string
.
ascii_lowercase
,
k
=
8
))
while
rand_str
in
used_names
:
rand_str
=
''
.
join
(
random
.
choices
(
string
.
ascii_uppercase
+
string
.
ascii_lowercase
,
k
=
8
))
used_names
.
append
(
rand_str
)
return
rand_str
...
...
@@ -20,27 +21,24 @@ def gen_rand_str():
def
get_rand_code
(
index
):
code
=
""
if
index
==
0
:
code
+=
";
\n
String "
+
gen_rand_str
()
+
"=
\"
"
+
gen_rand_str
()
+
"
\"
;"
code
+=
";
\n
String "
+
gen_rand_str
()
+
"=
\"
"
+
gen_rand_str
()
+
"
\"
;"
return
code
def
process_file_content
(
path
,
file_name
):
print
(
"processing content:
%
s..."
%
path
)
with
open
(
path
,
"rt"
)
as
fin
:
file_content
=
fin
.
read
()
line
=
get_rand_code
(
0
);
print
(
"processing content:
%
s"
%
line
)
file_content
.
replace
(
';'
,
line
)
ext
=
os
.
path
.
splitext
(
file_name
)[
1
]
if
ext
==
'.java'
:
comment
=
"// machine renamed:
%
s
\n
"
%
file_name
file_content
=
"
%
s
%
s"
%
(
comment
,
file_content
)
with
open
(
path
,
"wt"
)
as
fout
:
fout
.
write
(
file_content
)
def
process_file_content
(
path
,
file_name
):
print
(
"processing content:
%
s..."
%
path
)
with
open
(
x
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
# readlines以列表的形式将文件读出
lines
=
f
.
readlines
()
with
open
(
x
,
"w"
,
encoding
=
"utf-8"
)
as
f_w
:
for
line
in
lines
:
if
y
in
line
:
line
=
line
.
replace
(
";
\n
"
,
get_rand_code
(
0
))
f_w
.
write
(
line
)
print
(
"done
\n
"
)
return
# read configs
with
open
(
'obact.json'
,
"rt"
)
as
f
:
json_root
=
json
.
load
(
f
)
...
...
@@ -52,7 +50,6 @@ with open('obact.json', "rt") as f:
for
act_name
in
activities
:
activity_mangle_setting
[
act_name
]
=
gen_rand_str
()
root_path
=
os
.
path
.
join
(
os
.
getcwd
(),
source_root
)
# perform content replace for the files
print
(
"processing file content..."
)
...
...
@@ -62,11 +59,6 @@ for root, dirs, files in os.walk(source_root):
if
file
.
endswith
(
".java"
):
# get the path of the java file
path
=
os
.
path
.
join
(
directory
,
file
)
process_file_content
(
path
,
file
)
print
(
"processing file content done"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment