Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/python | |
| 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 | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 import optparse | |
| 7 import os | |
| 8 import pydoc | |
| 9 import shutil | |
| 10 import sys | |
| 11 | |
|
Nirnimesh
2011/08/26 00:50:17
2 lines at global scope please
| |
| 12 def main(): | |
| 13 parser = optparse.OptionParser() | |
| 14 parser.add_option('-w', '--write', dest='dir', metavar='FILE', | |
| 15 default=os.path.join(os.getcwd(), 'pyauto_docs'), | |
| 16 help='Directory path to write all of the documentation') | |
|
Nirnimesh
2011/08/26 00:50:17
Add: Defaults to "pyauto_docs" in current director
| |
| 17 parser.add_option('-p', '--pyauto', dest='pyauto', metavar='FILE', | |
|
Nirnimesh
2011/08/26 00:50:17
recommend renaming pyauto to pyautolib
| |
| 18 default=os.getcwd(), | |
| 19 help='Location of pyautolib directory') | |
| 20 (options, args) = parser.parse_args() | |
| 21 | |
| 22 if not os.path.isdir(options.dir): | |
| 23 os.makedirs(options.dir) | |
| 24 | |
| 25 # Add these paths so pydoc can find everything | |
| 26 sys.path.append(os.path.join(options.pyauto, | |
| 27 '../../../third_party/')) | |
| 28 sys.path.append(options.pyauto) | |
| 29 | |
| 30 # Get a snapshot of the current directory where pydoc will export the files | |
| 31 previous_contents = set(os.listdir(os.getcwd())) | |
| 32 pydoc.writedocs(options.pyauto) | |
| 33 current_contents = set(os.listdir(os.getcwd())) | |
| 34 | |
| 35 if options.dir == os.getcwd(): | |
| 36 print('Export complete, files are located in %s' % options.dir) | |
| 37 return | |
| 38 | |
| 39 new_files = current_contents.difference(previous_contents) | |
| 40 for file_name in new_files: | |
| 41 basename, extension = os.path.splitext(file_name) | |
| 42 if extension == '.html': | |
| 43 # Build the complete path | |
| 44 full_path = os.path.join(os.getcwd(), file_name) | |
| 45 existing_file_path = os.path.join(options.dir, file_name) | |
| 46 if os.path.isfile(existing_file_path): | |
| 47 os.remove(existing_file_path) | |
| 48 shutil.move(full_path, options.dir) | |
| 49 | |
| 50 print('Export complete, files are located in %s' % options.dir) | |
|
Nirnimesh
2011/08/26 00:50:17
Remove the parens in all print statements
| |
| 51 | |
|
Nirnimesh
2011/08/26 00:50:17
need 2 lines here
| |
| 52 if __name__ == '__main__': | |
| 53 main() | |
| 54 | |
| OLD | NEW |