Last active
January 23, 2016 00:47
-
-
Save nsporillo/11027146 to your computer and use it in GitHub Desktop.
Simple Python script which removes all comments from a source generated from JD-GUI
This file contains hidden or 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
import os | |
import fnmatch | |
import re | |
pattern = re.compile(r"(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/)|(//.*)") | |
for root, dirs, files in os.walk("."): | |
for name in fnmatch.filter(files, "*.java"): | |
file = os.path.join(root, name) | |
with open(file, mode='r+') as f: | |
rep = pattern.sub(r"", f.read()) | |
f.seek(0) | |
f.write(rep) | |
f.truncate() | |
print ("Successfully removed comments from:", file) | |
print ("Finished source file comment removal") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment