Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pathlib import Path
- import fileinput
- cs_list = list( Path("D:/_ССС/Types").rglob("*.cs") )
- special_list = set()
- dupl_list = set()
- for cs in cs_list:
- print(f"CS: {cs}")
- read_wait = False
- read_base = False
- read_lock = False
- offset = 8
- brackets = 0
- brackets_cnt = 0
- with fileinput.input(cs, inplace=True) as file:
- for line in file:
- if read_lock:
- print(line, end='')
- continue
- if line.find("public override void Read(") >= 0:
- offset = line.find("public override void Read(") + 4
- read_wait = True
- if read_wait:
- if line.find("base.Read(") >= 0:
- read_base = True
- if line.find("=>") >= 0:
- read_lock = True
- if line.find("for(") >= 0 or line.find("for (") >= 0:
- special_list.add(cs)
- if line.find("SetIsSerialized") >= 0:
- dupl_list.add(cs)
- for char in line:
- if char == '{':
- brackets += 1
- brackets_cnt += 1
- elif char == '}':
- brackets -= 1
- brackets_cnt += 1
- if brackets == 0 and brackets_cnt >= 2 and not read_lock:
- if read_base:
- print(f"{' ' * offset}//SetIsSerialized() in base")
- else:
- print(f"{' ' * offset}SetIsSerialized();")
- read_lock = True
- print(line, end='')
- if read_wait:
- print(f" read_wait = {read_wait}, read_base = {read_base}, offset = {offset}, brackets_cnt = {brackets_cnt}, brackets = {brackets}")
- else:
- print(f" ----------------")
- print(dupl_list)
- print("---------------")
- print(special_list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement