Last active
June 24, 2016 03:26
-
-
Save saitjr/7932b58537b787d2dc0af4f6aa1f1f68 to your computer and use it in GitHub Desktop.
delete annotate from project. Include `///<` and `//`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python | |
#coding:utf-8 | |
import re | |
import os | |
path = raw_input("folder path: ") | |
fileType = ['.m', '.h'] | |
for root, dirs, files in os.walk(path): | |
for name in files: | |
fileName, fileSuffix = os.path.splitext(name) | |
if fileSuffix in fileType: | |
old_file = os.path.join(root, name) | |
fopen = open(old_file,'r') | |
w_str = "" | |
for line in fopen: | |
if line == '\n': | |
w_str += line | |
continue | |
if re.search(r'[a-zA-z]+://[^\s]*$', line): | |
w_str += line | |
continue | |
line = re.sub(r'///<[^\\]*$', '\n', line) | |
if line == '\n': | |
continue | |
line = re.sub(r'//[^\\]*$', '\n', line) | |
if line != '\n': | |
w_str += line | |
continue | |
wopen = open(old_file,'w') | |
wopen.write(w_str) | |
fopen.close() | |
wopen.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment