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

Unified Diff: third_party/fontconfig/process-template.py

Issue 113203003: Fix Mac fontconfig build (Closed) Base URL: https://skia.googlesource.com/skia.git@noembed
Patch Set: checkpoint Created 7 years 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: third_party/fontconfig/process-template.py
diff --git a/third_party/fontconfig/process-template.py b/third_party/fontconfig/process-template.py
new file mode 100755
index 0000000000000000000000000000000000000000..b5273031a47872e960e9a8daf18368f3793f2a89
--- /dev/null
+++ b/third_party/fontconfig/process-template.py
@@ -0,0 +1,49 @@
+#!/usr/bin/python
epoger 2014/01/08 19:40:22 Add copyright and documentation header?
+
+import argparse
+import os
+import sys
+
+parser = argparse.ArgumentParser()
+parser.add_argument("-i", "--input")
epoger 2014/01/08 19:40:22 Please be consistent with either single- or double
vandebo (ex-Chrome) 2014/01/08 21:24:15 Done.
+parser.add_argument("-o", "--output")
+parser.add_argument(
epoger 2014/01/08 19:40:22 I would suggest naming this arg --keyword_substitu
vandebo (ex-Chrome) 2014/01/08 21:24:15 Done.
+ "-s", "--substitution", action="append", nargs=2, metavar=('KEY', 'VALUE'), help="Changes @KEY@ to VALUE in the template.")
bungeman-skia 2014/01/07 21:13:29 nit: this line is a bit long, looks like the next
vandebo (ex-Chrome) 2014/01/08 21:24:15 Done.
+parser.add_argument(
+ "-p", "--path_substitution", action="append", nargs=2,
+ metavar=('KEY', 'PATH'),
+ help="Makes PATH absolute then changes @KEY@ to PATH in the template.")
+
+args = parser.parse_args()
+
+input = sys.stdin
+if args.input:
+ try:
+ input = open(args.input, 'r')
+ except IOError:
epoger 2014/01/08 19:40:22 Why the manual try/except handling? If you just d
vandebo (ex-Chrome) 2014/01/08 21:24:15 Done.
+ sys.exit(1)
+
+output = sys.stdout
+if args.output:
+ try:
+ output = open(args.output, 'w')
+ except IOError:
+ sys.exit(1)
+
+path_subs = None
+if args.path_substitution:
+ path_subs = [
+ [sub[0], os.path.abspath(sub[1])] for sub in args.path_substitution
+ ]
+
+for line in input:
+ if args.substitution:
+ for (key, value) in args.substitution:
+ line = line.replace('@' + key + '@', value)
epoger 2014/01/08 19:40:22 Rather than mandating the @ delimiters, why not ju
vandebo (ex-Chrome) 2014/01/08 21:24:15 Done.
+ if path_subs:
+ for (key, path) in path_subs:
+ line = line.replace('@' + key + '@', path)
+ output.write(line)
+
+input.close()
+output.close()
« third_party/fontconfig/README.chromium ('K') | « third_party/fontconfig/config/mac/config.h.template ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698