-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcode_processor.py
More file actions
28 lines (22 loc) · 777 Bytes
/
code_processor.py
File metadata and controls
28 lines (22 loc) · 777 Bytes
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
import os
from pathlib import Path
path = "/home/pc/Downloads/JDK-master/src/java/"
dest = "./jdk-chars.txt"
for subdir, dirs, files in os.walk(path):
for file in files:
name = os.path.join(subdir, file)
if name.endswith(".java"):
print(name)
with open(name) as f:
content = f.readlines()
# you may also want to remove whitespace characters like `\n` at the end of each line
content = [x.strip() for x in content]
for line in content:
if line.startswith("//"):
continue
if len(line)==0:
continue
with open(dest, "a") as myfile:
myfile.write(line+"\n")
"""
"""