Commit 58511681 by sikang

update

parent deb75b02
...@@ -54,6 +54,11 @@ def get_brackets(line): ...@@ -54,6 +54,11 @@ def get_brackets(line):
right = line.count("}") right = line.count("}")
return left - right return left - right
def is_note(line):
final_line = line.replace("://","")
return "//" in final_line or "\t*" in final_line
def process_file_content(path, file_name): def process_file_content(path, file_name):
# print("processing content: %s..." % path) # print("processing content: %s..." % path)
with open(path, "r", encoding="utf-8") as f: with open(path, "r", encoding="utf-8") as f:
...@@ -70,7 +75,7 @@ def process_file_content(path, file_name): ...@@ -70,7 +75,7 @@ def process_file_content(path, file_name):
#接口和抽象类 直接跳过 #接口和抽象类 直接跳过
if "interface" in line or "abstract" in line: if "interface" in line or "abstract" in line:
isAbstract=True isAbstract=True
if isAbstract or "//" in line or "*" in line: if isAbstract or is_note(line):
f_w.write(line) f_w.write(line)
continue continue
...@@ -80,8 +85,7 @@ def process_file_content(path, file_name): ...@@ -80,8 +85,7 @@ def process_file_content(path, file_name):
#return后有多行代码 #return后有多行代码
if "return" in line or ("throw" in line and not isReturn): if "return" in line or ("throw" in line and not isReturn):
isReturn = True isReturn = True
return_level = 0 return_level = get_brackets(line)
if isReturn: if isReturn:
return_level += get_brackets(line) return_level += get_brackets(line)
...@@ -113,10 +117,10 @@ def process_file_content(path, file_name): ...@@ -113,10 +117,10 @@ def process_file_content(path, file_name):
"throw" not in line and \ "throw" not in line and \
"};" not in line and \ "};" not in line and \
"});" not in line and \ "});" not in line and \
"//" not in line: not is_note(line):
if random.randint(0, 20) % 2 == 0: # if random.randint(0, 20) % 2 == 0:
line = line.replace(";\n", get_rand_code(func_level>0)) line = line.replace(";\n", get_rand_code(func_level>0))
if ";" in line : if ";" in line :
isErrorIf = False isErrorIf = False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment