Make the script support multiple input files

pull/3961/head
Jorge Canizales 9 years ago
parent 88c3284349
commit bbb7774b83
  1. 14
      src/objective-c/change-comments.py
  2. 3
      src/objective-c/format-all-comments.sh

@ -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

@ -0,0 +1,3 @@
#!/usr/bin/bash
find . -type f -name "*.h" ! -path "*/Pods/*" ! -path "./generated_libraries/*" ! -path "./examples/*" ! -path "./tests/*" | xargs ./change-comments.py
Loading…
Cancel
Save