Index: chrome/common/extensions/docs/server2/samples_data_source.py |
diff --git a/chrome/common/extensions/docs/server2/samples_data_source.py b/chrome/common/extensions/docs/server2/samples_data_source.py |
index 9a57fba423a1f2d1eebf76b3eb40331cbcdda94f..29b45a92b652cf52401e5fd294f5171ea7156b0e 100644 |
--- a/chrome/common/extensions/docs/server2/samples_data_source.py |
+++ b/chrome/common/extensions/docs/server2/samples_data_source.py |
@@ -56,14 +56,14 @@ class SamplesDataSource(object): |
request) |
def _GetAPIItems(self, js_file): |
- chrome_regex = '(chrome\.[a-zA-Z0-9\.]+)' |
+ chrome_regex = r'(chrome\.[a-zA-Z0-9\.]+)' |
calls = set(re.findall(chrome_regex, js_file)) |
# Find APIs that have been assigned into variables. |
- assigned_vars = dict(re.findall('var\s*([^\s]+)\s*=\s*%s;' % chrome_regex, |
- js_file)) |
+ assigned_vars = dict( |
+ re.findall(r'var\s*([^\s]+)\s*=\s*%s;' % chrome_regex, js_file)) |
# Replace the variable name with the full API name. |
for var_name, value in assigned_vars.iteritems(): |
Jeffrey Yasskin
2013/11/01 18:00:24
You might be able to make this loop more efficient
|
- js_file = js_file.replace(var_name, value) |
+ js_file = re.compile(r'\b%s\b' % var_name).sub(value, js_file) |
not at google - send to devlin
2013/11/01 17:12:04
this is the most important change.
Jeffrey Yasskin
2013/11/01 18:00:24
Instead of re.compile(variable_string).sub(...), u
Jeffrey Yasskin
2013/11/01 18:00:24
You probably want re.escape(var_name) in case it c
|
return calls.union(re.findall(chrome_regex, js_file)) |
Jeffrey Yasskin
2013/11/01 18:00:24
Wait a second, you're just trying to find the APIs
not at google - send to devlin
2013/11/04 21:51:01
I got a little bit lost in your comments there + t
|
def _GetDataFromManifest(self, path, file_system): |