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

Side by Side Diff: third_party/fontconfig/process-template.py

Issue 132333002: Fix Mac fontconfig build (try 2) (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: comments Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/fontconfig/config/mac/config.h.template ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
2
3 # Copyright 2014 Google Inc.
4 #
5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file.
7
8 # A simple template processing script.
9
10 import optparse
11 import os
12 import sys
13
14 parser = optparse.OptionParser()
15 parser.add_option('-i', '--input')
16 parser.add_option('-o', '--output')
17 parser.add_option(
18 '-k', '--keyword_substitution', action='append', nargs=2,
19 metavar=('KEY', 'VALUE'), help='Changes KEY to VALUE in the template.')
20 parser.add_option(
21 '-p', '--path_substitution', action='append', nargs=2,
22 metavar=('KEY', 'PATH'),
23 help='Makes PATH absolute then changes KEY to PATH in the template.')
24
25 (args, _) = parser.parse_args()
26
27 input = sys.stdin
28 if args.input:
29 input = open(args.input, 'r')
30
31 output = sys.stdout
32 if args.output:
33 output = open(args.output, 'w')
34
35 path_subs = None
36 if args.path_substitution:
37 path_subs = [
38 [sub[0], os.path.abspath(sub[1])] for sub in args.path_substitution
39 ]
40
41 for line in input:
42 if args.keyword_substitution:
43 for (key, value) in args.keyword_substitution:
44 line = line.replace(key, value)
45 if path_subs:
46 for (key, path) in path_subs:
47 line = line.replace(key, path)
48 output.write(line)
49
50 input.close()
51 output.close()
OLDNEW
« no previous file with comments | « 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