Mercurial > hg > MakeItSo
comparison makeitso/makeitso.py @ 15:edabb0bfe107
add method to work TTW
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 15 Nov 2010 18:26:21 -0800 |
parents | 99588f138993 |
children | 1818cc524cde |
comparison
equal
deleted
inserted
replaced
14:bf1ce840d0f0 | 15:edabb0bfe107 |
---|---|
5 | 5 |
6 import os | 6 import os |
7 import re | 7 import re |
8 import subprocess | 8 import subprocess |
9 import sys | 9 import sys |
10 import urllib | |
10 | 11 |
11 from optparse import OptionParser | 12 from optparse import OptionParser |
12 | 13 |
13 | 14 |
14 try: | 15 try: |
101 parser = OptionParser(usage, description=__doc__) | 102 parser = OptionParser(usage, description=__doc__) |
102 parser.add_option('-[', '--start-braces', dest='start_braces', | 103 parser.add_option('-[', '--start-braces', dest='start_braces', |
103 help='starting delimeter') | 104 help='starting delimeter') |
104 parser.add_option('-]', '--end-braces', dest='end_braces', | 105 parser.add_option('-]', '--end-braces', dest='end_braces', |
105 help='starting delimeter') | 106 help='starting delimeter') |
107 parser.add_option('--in-place', dest='in_place', | |
108 action='store_true', default=False, | |
109 help='interpret files in place') # TODO: unused | |
106 parser.add_option('--commandline', dest='commandline', | 110 parser.add_option('--commandline', dest='commandline', |
107 action='store_true', default=False, | 111 action='store_true', default=False, |
108 help="print the commandline to invoke this script TTW") | 112 help="print the commandline to invoke this script TTW") |
109 parser.add_option('--variables', dest='variables', | 113 parser.add_option('--variables', dest='variables', |
110 action='store_true', default=False, | 114 action='store_true', default=False, |
153 return | 157 return |
154 | 158 |
155 # get the content | 159 # get the content |
156 if args: | 160 if args: |
157 for arg in args: | 161 for arg in args: |
158 content = file(arg).read() | 162 f, headers = urllib.urlretrieve(arg) |
163 content = file(f).read() | |
159 substitute(content, variables=variables) | 164 substitute(content, variables=variables) |
160 else: | 165 else: |
161 content = sys.stdin.read() | 166 content = sys.stdin.read() |
162 substitute(content, variables=variables) | 167 substitute(content, variables=variables) |
163 | 168 |