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

Side by Side Diff: chrome/tools/webforms_extractor.py

Issue 8680018: Fix python scripts in src/chrome/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: copyright Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/tools/webforms_aggregator_unittests.py ('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
1 #!/usr/bin/python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be found 3 # Use of this source code is governed by a BSD-style license that can be found
4 # in the LICENSE file. 4 # in the LICENSE file.
5 5
6 """Extracts registration forms from the corresponding HTML files. 6 """Extracts registration forms from the corresponding HTML files.
7 7
8 Used for extracting forms within HTML files. This script is used in 8 Used for extracting forms within HTML files. This script is used in
9 conjunction with the webforms_aggregator.py script, which aggregates web pages 9 conjunction with the webforms_aggregator.py script, which aggregates web pages
10 with fillable forms (i.e registration forms). 10 with fillable forms (i.e registration forms).
11 11
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 with open(numbered_form_filename, 'w') as f: 221 with open(numbered_form_filename, 'w') as f:
222 f.write(form_location_comment) 222 f.write(form_location_comment)
223 f.write(form_content) 223 f.write(form_content)
224 except IOError as e: 224 except IOError as e:
225 self.logger.error('Error: %s', e) 225 self.logger.error('Error: %s', e)
226 continue 226 continue
227 self.logger.info('\tFile "%s" extracted SUCCESSFULLY!', filename) 227 self.logger.info('\tFile "%s" extracted SUCCESSFULLY!', filename)
228 228
229 229
230 def main(): 230 def main():
231 # Command line options.
232 parser = OptionParser() 231 parser = OptionParser()
233 parser.add_option( 232 parser.add_option(
234 '-l', '--log_level', metavar='LOG_LEVEL', default='error', 233 '-l', '--log_level', metavar='LOG_LEVEL', default='error',
235 help='LOG_LEVEL: debug, info, warning or error [default: %default]') 234 help='LOG_LEVEL: debug, info, warning or error [default: %default]')
236 parser.add_option( 235 parser.add_option(
237 '-j', '--js', dest='js', action='store_true', default=False, 236 '-j', '--js', dest='js', action='store_true', default=False,
238 help='Removes all javascript elements [default: %default]') 237 help='Removes all javascript elements [default: %default]')
239 238
240 (options, args) = parser.parse_args() 239 (options, args) = parser.parse_args()
241 options.log_level = options.log_level.upper() 240 options.log_level = options.log_level.upper()
242 if options.log_level not in ['DEBUG', 'INFO', 'WARNING', 'ERROR']: 241 if options.log_level not in ['DEBUG', 'INFO', 'WARNING', 'ERROR']:
243 print 'Wrong log_level argument.' 242 print 'Wrong log_level argument.'
244 parser.print_help() 243 parser.print_help()
245 sys.exit(1) 244 return 1
246 245
247 options.log_level = getattr(logging, options.log_level) 246 options.log_level = getattr(logging, options.log_level)
248 extractor = FormsExtractor(logging_level=options.log_level) 247 extractor = FormsExtractor(logging_level=options.log_level)
249 extractor.Extract(options.js) 248 extractor.Extract(options.js)
249 return 0
250 250
251 251
252 if __name__ == '__main__': 252 if __name__ == '__main__':
253 main() 253 sys.exit(main())
OLDNEW
« no previous file with comments | « chrome/tools/webforms_aggregator_unittests.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698