109: #line 121 "interscript_options.ipk"
110: class argument_frame:
111: def copy(self):
112: other = argument_frame()
113: for k in self.__dict__.keys():
114: setattr(other,k,getattr(self,k))
115: return other
116:
117: def getoption_frames(args):
118: parsed = getopt(args)
119: process_options = argument_frame()
120: process_options.logfile = None
121: process_options.logfile_mode = None
122: process_options.break_on_error = 0
123: process_options.args = args
124: process_options.trace = []
125: master_frames = []
126:
127: frame = argument_frame()
128: frame.update_files = 1
129: frame.tabwidth = 8
130: frame.download = 'regularly'
131: frame.refresh_interval = 28
132: frame.usecache = 1
133: frame.passes = 1
134: frame.weaver_prefix = ''
135: frame.tangler_prefix = ''
136: frame.weaver_directory= ''
137: frame.tangler_directory = ''
138: frame.autoweave = []
139: frame.useropt = {}
140: frame.encoding='utf8'
141: frame.html_eol = '\n'
142: frame.title = None
143: frame.languages = []
144: for opts,filename in parsed:
145: for opt,value in opts:
146: try:
147: if opt == 'break-on-error': process_options.break_on_error=1
148: elif opt == 'v': process_options.trace = [
149: 'options',
150: 'frames',
151: 'input',
152: 'weavers',
153: 'tanglers',
154: 'lines',
155: 'sources',
156: 'sinks',
157: 'script',
158: 'cache',
159: 'deps']
160: elif opt == 'noupdate': frame.update_files = 0
161: elif opt == 'nocache': frame.usecache = 0
162: elif opt == 'nodownload': frame.download = 'never'
163: elif opt == 'download': frame.download = 'always'
164: elif opt == 'tabwidth': frame.tabwidth = int(value)
165: elif opt == 'passes': frame.passes = int(value)
166: elif opt == 'weaver': frame.autoweave.append(value)
167: elif opt == 'weaver-prefix': frame.weaver_prefix = value
168: elif opt == 'title': frame.title = value
169: elif opt == 'tangler-prefix': frame.tangler_prefix = value
170: elif opt == 'weaver-directory': frame.weaver_directory = value
171: elif opt == 'weaver-directory': frame.weaver_directory = value
172: elif opt == 'language': frame.languages.append(value)
173: elif opt == 'encoding': frame.encoding=value
174: elif opt == 'trace': process_options.trace.append(value)
175: elif opt == 'html-eol':
176: if sys.platform == 'Win32':
177: print 'CRLF kludge ignored for Win32'
178: print 'Use on Unix only, to make html files in DOS format'
179: else:
180: frame.html_eol = '\r\n'
181: elif opt == 'tangler-directory': frame.tangler_directory = value
182: elif opt == 'homepage':
183: print 'http://www.triode.net.au/~skaller/interscript'
184: elif opt == 'author':
185: print 'mailto:skaller@maxtal.com.au <John Skaller>'
186: elif opt == 'copyright':
187: print 'Copyright (C)1998 Maxtal P/L Australia'
188: elif opt == 'licence':
189: print 'Free for any use'
190: elif opt == 'executable':
191: print sys.executable
192: elif opt == 'python-version':
193: print sys.version
194: elif opt == 'python':
195: try:
196: if 'script' in process_options.trace:
197: print 'Executing python:'
198: print value
199: exec value
200: except:
201: print 'Error in python option'
202: traceback.print_exc()
203: elif opt == 'logfile':
204: process_options.logfile = value
205: process_options.logfile_mode = 'a'
206: elif opt == 'new-logfile':
207: process_options.logfile = value
208: process_options.logfile_mode = 'w'
209: elif opt in ['help', 'usage']:
210: print_help()
211: print
212: else:
213:
214: print 'Nonstandard option',opt,'value',value,'accepted as user option'
215: frame.useropt[opt]=value
216: if 'options' in process_options.trace: print 'Option:',opt,value
217: except:
218: print 'Warning: Option',opt,'has bad value',value
219: prefix = ''
220: while opt[0]=='-': prefix = prefix + '-'; opt=opt[1:]
221: print_help1(opt)
222:
223: files = glob.glob( filename)
224: for file in files:
225: frame.source_prefix, frame.filename = os.path.split(file)
226: if frame.source_prefix != '':
227: frame.source_prefix = frame.source_prefix + os.sep
228: master_frames.append(frame.copy())
229: return process_options, master_frames
230:
231: