| OLD | NEW |
| 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import optparse | 6 import optparse |
| 7 import os | 7 import os |
| 8 import pydoc | 8 import pydoc |
| 9 import shutil | 9 import shutil |
| 10 import sys | 10 import sys |
| 11 | 11 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 29 '../../../third_party/')) | 29 '../../../third_party/')) |
| 30 sys.path.append(options.pyautolib) | 30 sys.path.append(options.pyautolib) |
| 31 | 31 |
| 32 # Get a snapshot of the current directory where pydoc will export the files | 32 # Get a snapshot of the current directory where pydoc will export the files |
| 33 previous_contents = set(os.listdir(os.getcwd())) | 33 previous_contents = set(os.listdir(os.getcwd())) |
| 34 pydoc.writedocs(options.pyautolib) | 34 pydoc.writedocs(options.pyautolib) |
| 35 current_contents = set(os.listdir(os.getcwd())) | 35 current_contents = set(os.listdir(os.getcwd())) |
| 36 | 36 |
| 37 if options.dir == os.getcwd(): | 37 if options.dir == os.getcwd(): |
| 38 print 'Export complete, files are located in %s' % options.dir | 38 print 'Export complete, files are located in %s' % options.dir |
| 39 return | 39 return 1 |
| 40 | 40 |
| 41 new_files = current_contents.difference(previous_contents) | 41 new_files = current_contents.difference(previous_contents) |
| 42 for file_name in new_files: | 42 for file_name in new_files: |
| 43 basename, extension = os.path.splitext(file_name) | 43 basename, extension = os.path.splitext(file_name) |
| 44 if extension == '.html': | 44 if extension == '.html': |
| 45 # Build the complete path | 45 # Build the complete path |
| 46 full_path = os.path.join(os.getcwd(), file_name) | 46 full_path = os.path.join(os.getcwd(), file_name) |
| 47 existing_file_path = os.path.join(options.dir, file_name) | 47 existing_file_path = os.path.join(options.dir, file_name) |
| 48 if os.path.isfile(existing_file_path): | 48 if os.path.isfile(existing_file_path): |
| 49 os.remove(existing_file_path) | 49 os.remove(existing_file_path) |
| 50 shutil.move(full_path, options.dir) | 50 shutil.move(full_path, options.dir) |
| 51 | 51 |
| 52 print 'Export complete, files are located in %s' % options.dir | 52 print 'Export complete, files are located in %s' % options.dir |
| 53 return 0 |
| 53 | 54 |
| 54 | 55 |
| 55 if __name__ == '__main__': | 56 if __name__ == '__main__': |
| 56 main() | 57 sys.exit(main()) |
| 57 | |
| OLD | NEW |