Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(503)

Unified Diff: testing/tools/fixup_pdf_template.py

Issue 912803004: Create run_javascript_tests.py (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Address nits. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: testing/tools/fixup_pdf_template.py
diff --git a/testing/tools/fixup_pdf_template.py b/testing/tools/fixup_pdf_template.py
index 87996a42cd58e0506054fd4b880d7bd12c61e58b..a43db55ee9f51b9f8ab1889c46e1de88ac7e6d06 100755
--- a/testing/tools/fixup_pdf_template.py
+++ b/testing/tools/fixup_pdf_template.py
@@ -70,22 +70,32 @@ class TemplateProcessor:
self.offset += len(line)
return line
-def expand_file(input_filename):
- (input_root, extension) = os.path.splitext(input_filename)
- output_filename = input_root + '.pdf'
+
+def expand_file(input_path, output_path):
processor = TemplateProcessor()
try:
- with open(input_filename, 'r') as infile:
- with open(output_filename, 'w') as outfile:
+ with open(input_path, 'r') as infile:
+ with open(output_path, 'w') as outfile:
for line in infile:
outfile.write(processor.process_line(line))
except IOError:
- print >> sys.stderr, 'failed to process %s' % input_filename
+ print >> sys.stderr, 'failed to process %s' % input_path
+
def main():
- for arg in sys.argv[1:]:
- expand_file(arg)
+ parser = optparse.OptionParser()
+ parser.add_option('--output-dir', default='')
+ options, args = parser.parse_args()
+ for testcase_path in args:
+ testcase_filename = os.path.basename(testcase_path)
+ testcase_root, _ = os.path.splitext(testcase_filename)
+ output_dir = os.path.dirname(testcase_path)
+ if options.output_dir:
+ output_dir = options.output_dir
+ output_path = os.path.join(output_dir, testcase_root + '.pdf')
+ expand_file(testcase_path, output_path)
return 0
+
if __name__ == '__main__':
sys.exit(main())

Powered by Google App Engine
This is Rietveld 408576698