| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 import logging | 4 import logging |
| 5 import optparse | 5 import optparse |
| 6 import os | 6 import os |
| 7 import pkgutil | 7 import pkgutil |
| 8 import pydoc | 8 import pydoc |
| 9 import re | 9 import re |
| 10 import sys | 10 import sys |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 def RemoveAllStalePycFiles(): | 26 def RemoveAllStalePycFiles(): |
| 27 for dirname, _, filenames in os.walk(telemetry_dir): | 27 for dirname, _, filenames in os.walk(telemetry_dir): |
| 28 for filename in filenames: | 28 for filename in filenames: |
| 29 if not filename.endswith('.pyc'): | 29 if not filename.endswith('.pyc'): |
| 30 continue | 30 continue |
| 31 pyc_path = os.path.join(dirname, filename) | 31 pyc_path = os.path.join(dirname, filename) |
| 32 py_path = os.path.splitext(pyc_path)[0] + '.py' | 32 py_path = os.path.splitext(pyc_path)[0] + '.py' |
| 33 if not os.path.exists(py_path): | 33 if not os.path.exists(py_path): |
| 34 os.remove(pyc_path) | 34 os.remove(pyc_path) |
| 35 pyc_dir = os.path.dirname(pyc_path) |
| 36 if not os.listdir(pyc_dir): |
| 37 os.removedirs(pyc_dir) |
| 35 | 38 |
| 36 def GenerateHTMLForModule(module): | 39 def GenerateHTMLForModule(module): |
| 37 html = pydoc.html.page(pydoc.describe(module), | 40 html = pydoc.html.page(pydoc.describe(module), |
| 38 pydoc.html.document(module, module.__name__)) | 41 pydoc.html.document(module, module.__name__)) |
| 39 | 42 |
| 40 # pydoc writes out html with links in a variety of funky ways. We need | 43 # pydoc writes out html with links in a variety of funky ways. We need |
| 41 # to fix them up. | 44 # to fix them up. |
| 42 assert not telemetry_dir.endswith(os.sep) | 45 assert not telemetry_dir.endswith(os.sep) |
| 43 links = re.findall('(<a href="(.+?)">(.+?)</a>)', html) | 46 links = re.findall('(<a href="(.+?)">(.+?)</a>)', html) |
| 44 for link_match in links: | 47 for link_match in links: |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 EnsureTelemetryIsInPath() | 162 EnsureTelemetryIsInPath() |
| 160 import telemetry | 163 import telemetry |
| 161 | 164 |
| 162 old_cwd = os.getcwd() | 165 old_cwd = os.getcwd() |
| 163 try: | 166 try: |
| 164 os.chdir(telemetry_dir) | 167 os.chdir(telemetry_dir) |
| 165 for module in GetAllModulesToDocument(telemetry): | 168 for module in GetAllModulesToDocument(telemetry): |
| 166 WriteHTMLForModule(module) | 169 WriteHTMLForModule(module) |
| 167 finally: | 170 finally: |
| 168 os.chdir(old_cwd) | 171 os.chdir(old_cwd) |
| OLD | NEW |