Example #1
0
        print("Making a comment-stripped copy in .nocomments" + path[1:] +
              " of: ",
              end="")
    elif mode == "succinct":
        print(".", end="")
        sys.stdout.flush()

    for filename in filenames:
        if not filename.endswith(".java"): continue

        fullpath = os.path.join(path, filename)
        newcopy = ".nocomments" + fullpath[1:]  # replace . with .nocomments

        if mode == "normal":
            print(filename, end=" ")
        elif mode == "succinct":
            print(".", end="")
            sys.stdout.flush()

        fin = open(fullpath)
        original = fin.read()
        fin.close()

        fout = open(newcopy, 'w')
        nocomments = java_syntax.java_parse(original).get_text(
            keep_comments=False, tabify=True)
        print(nocomments, file=fout, end="")
    if mode == "normal": print()
if mode == "succinct":
    print()
Example #2
0
#!/usr/bin/python3

# Stdin: a Java program
# Stdout: the same Java program with all comments removed, tabified, no blank lines

import java_syntax, sys

print(java_syntax.java_parse(sys.stdin.read()).get_text(keep_comments=False,
                                                        tabify=True),
      end="")
Example #3
0
#!/usr/bin/python3

# Stdin: a Java program
# Stdout: the same Java program with all comments removed, tabified, no blank lines

import java_syntax, sys

print(java_syntax.java_parse(sys.stdin.read()).get_text(keep_comments = False, tabify = True), end="")
Example #4
0
    if path.startswith("./."): continue # skip "hidden" directories
    os.system("mkdir .nocomments" + path[1:])

    if mode == "normal":
        print("Making a comment-stripped copy in .nocomments" + path[1:] + " of: ", end="")
    elif mode == "succinct":
        print(".", end="")
        sys.stdout.flush()

    for filename in filenames:
        if not filename.endswith(".java"): continue

        fullpath = os.path.join(path, filename)
        newcopy = ".nocomments" + fullpath[1:] # replace . with .nocomments
        
        if mode == "normal":
            print(filename, end=" ")
        elif mode == "succinct":
            print(".", end="")
            sys.stdout.flush()
        
        fin = open(fullpath)
        original = fin.read()
        fin.close()
        
        fout = open(newcopy, 'w')
        nocomments = java_syntax.java_parse(original).get_text(keep_comments = False, tabify = True)
        print(nocomments, file=fout, end="")
    if mode == "normal": print()
if mode == "succinct": print()