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

Side by Side Diff: tools/telemetry/refactor.py

Issue 1132103009: Example of refactoring using rope library. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months 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
OLDNEW
(Empty)
1 import os
2
3 from telemetry.core import util
4
5 util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'rope')
6
7 from rope.refactor import rename
8 import rope.base.project
9
10
11 telemetry_path = os.path.dirname(__file__)
12 telemetry_project = rope.base.project.Project(telemetry_path)
13
14
15 def Rename(resource, offset, new_name):
16 changes = rename.Rename(
17 telemetry_project, resource, offset).get_changes(new_name)
18 print changes.get_description()
19 telemetry_project.do(changes)
20
21 user_story_file_path = os.path.join(
22 'telemetry', 'internal', 'story_runner.py')
23
24 user_story_code = telemetry_project.get_resource(user_story_file_path)
25 Rename(user_story_code,
26 user_story_code.read().index('def StoriesGroupedByStateClass') + 4,
27 'StoriesByStateClass')
OLDNEW
« no previous file with comments | « tools/telemetry/.ropeproject/config.py ('k') | tools/telemetry/telemetry/internal/story_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698