diff options
author | dtu@chromium.org <dtu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-02 22:02:23 +0000 |
---|---|---|
committer | dtu@chromium.org <dtu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-02 22:02:23 +0000 |
commit | f9ba3eaec2a68a2b22891bc131628075af40e94e (patch) | |
tree | 66874c6e278f34f6581764912abff1aee405c7c8 /tools/telemetry | |
parent | d68bac53fc00978eae9bf171ac23a92da7f73ba5 (diff) | |
download | chromium_src-f9ba3eaec2a68a2b22891bc131628075af40e94e.zip chromium_src-f9ba3eaec2a68a2b22891bc131628075af40e94e.tar.gz chromium_src-f9ba3eaec2a68a2b22891bc131628075af40e94e.tar.bz2 |
[telemetry] Move stale .pyc check from update_docs to __init__.py
Also remove Telemetry path check from update_docs. It has a dependency on Telemetry anyway.
BUG=None.
TEST=Ran it.
R=nduca@chromium.org
Review URL: https://codereview.chromium.org/18578002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209789 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/telemetry')
-rw-r--r-- | tools/telemetry/build/update_docs.py | 27 | ||||
-rw-r--r-- | tools/telemetry/telemetry/__init__.py | 22 |
2 files changed, 20 insertions, 29 deletions
diff --git a/tools/telemetry/build/update_docs.py b/tools/telemetry/build/update_docs.py index cae96e6..8c42b30 100644 --- a/tools/telemetry/build/update_docs.py +++ b/tools/telemetry/build/update_docs.py @@ -9,33 +9,17 @@ import pydoc import re import sys +import telemetry from telemetry.core import util telemetry_dir = util.GetTelemetryDir() docs_dir = os.path.join(telemetry_dir, 'docs') -def EnsureTelemetryIsInPath(): - if telemetry_dir not in sys.path: - sys.path.append(telemetry_dir) - def RemoveAllDocs(): for dirname, _, filenames in os.walk(docs_dir): for filename in filenames: os.remove(os.path.join(dirname, filename)) -def RemoveAllStalePycFiles(): - for dirname, _, filenames in os.walk(telemetry_dir): - for filename in filenames: - if not filename.endswith('.pyc'): - continue - pyc_path = os.path.join(dirname, filename) - py_path = os.path.splitext(pyc_path)[0] + '.py' - if not os.path.exists(py_path): - os.remove(pyc_path) - pyc_dir = os.path.dirname(pyc_path) - if not os.listdir(pyc_dir): - os.removedirs(pyc_dir) - def GenerateHTMLForModule(module): html = pydoc.html.page(pydoc.describe(module), pydoc.html.document(module, module.__name__)) @@ -50,7 +34,7 @@ def GenerateHTMLForModule(module): continue new_href = href.replace('file:', '') - new_href = new_href.replace(telemetry_dir, '..') + new_href = new_href.replace(telemetry_dir, os.pardir) new_href = new_href.replace(os.sep, '/') new_link_text = link_text.replace(telemetry_dir + os.sep, '') @@ -72,7 +56,6 @@ def WriteHTMLForModule(module): f.write(page) def GetAllModulesToDocument(module): - RemoveAllStalePycFiles() modules = [module] for _, modname, _ in pkgutil.walk_packages( module.__path__, module.__name__ + '.'): @@ -113,9 +96,6 @@ def GetAlreadyDocumentedModules(): def IsUpdateDocsNeeded(): - EnsureTelemetryIsInPath() - import telemetry - already_documented_modules = GetAlreadyDocumentedModules() already_documented_modules_by_name = dict( (module.name, module) for module in already_documented_modules) @@ -159,9 +139,6 @@ def Main(args): RemoveAllDocs() - EnsureTelemetryIsInPath() - import telemetry - old_cwd = os.getcwd() try: os.chdir(telemetry_dir) diff --git a/tools/telemetry/telemetry/__init__.py b/tools/telemetry/telemetry/__init__.py index 391a71e6..b4eb0df 100644 --- a/tools/telemetry/telemetry/__init__.py +++ b/tools/telemetry/telemetry/__init__.py @@ -30,7 +30,21 @@ for x in dir(): inspect.isfunction(getattr(m, x))): __all__.append(x) -# TODO: Remove this eventually. This is because a stale .pyc file in that -# directory are conflicting with test.py. http://crbug.com/252808 -if os.path.isdir(os.path.join(os.path.dirname(__file__), 'test')): - shutil.rmtree(os.path.join(os.path.dirname(__file__), 'test')) + +def _RemoveAllStalePycFiles(): + for dirname, _, filenames in os.walk(os.path.dirname(__file__)): + for filename in filenames: + root, ext = os.path.splitext(filename) + if ext != '.pyc': + continue + + pyc_path = os.path.join(dirname, filename) + py_path = os.path.join(dirname, root + '.py') + if not os.path.exists(py_path): + os.remove(pyc_path) + + if not os.listdir(dirname): + os.removedirs(dirname) + + +_RemoveAllStalePycFiles() |