|
|
|
@ -4,12 +4,14 @@ import re |
|
|
|
|
import sys |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(sys.argv) != 2: |
|
|
|
|
print("Please provide a source file name as only argument.") |
|
|
|
|
if len(sys.argv) < 2: |
|
|
|
|
print("Please provide at least one source file name as argument.") |
|
|
|
|
quit() |
|
|
|
|
|
|
|
|
|
for file_name in sys.argv[1:]: |
|
|
|
|
|
|
|
|
|
print("Modifying format of {file} comments in place...".format( |
|
|
|
|
file = sys.argv[1], |
|
|
|
|
file = file_name, |
|
|
|
|
)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -17,7 +19,7 @@ print("Modifying format of {file} comments in place...".format( |
|
|
|
|
|
|
|
|
|
lines = [] |
|
|
|
|
|
|
|
|
|
with open(sys.argv[1], "r") as input_file: |
|
|
|
|
with open(file_name, "r") as input_file: |
|
|
|
|
lines = input_file.readlines() |
|
|
|
|
|
|
|
|
|
def peek(): |
|
|
|
@ -38,7 +40,7 @@ def write(line): |
|
|
|
|
output_lines.append(line) |
|
|
|
|
|
|
|
|
|
def flush_output(): |
|
|
|
|
with open(sys.argv[1], "w") as otuput_file: |
|
|
|
|
with open(file_name, "w") as otuput_file: |
|
|
|
|
for line in output_lines: |
|
|
|
|
otuput_file.write(line) |
|
|
|
|
|
|
|
|
@ -79,7 +81,7 @@ def format_as_block(comment_block): |
|
|
|
|
return [indent + "/** " + content(comment_block[0]) + " */\n"] |
|
|
|
|
|
|
|
|
|
block = ["/**"] + [" * " + content(line) for line in comment_block] + [" */"] |
|
|
|
|
return [indent + line + "\n" for line in block] |
|
|
|
|
return [indent + line.rstrip() + "\n" for line in block] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Main algorithm |
|
|
|
|