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

Side by Side Diff: tools/metrics/actions/extract_actions.py

Issue 850043009: Fix error introduced in extract_actions.py. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Extract UserMetrics "actions" strings from the Chrome source. 7 """Extract UserMetrics "actions" strings from the Chrome source.
8 8
9 This program generates the list of known actions we expect to see in the 9 This program generates the list of known actions we expect to see in the
10 user behavior logs. It walks the Chrome source, looking for calls to 10 user behavior logs. It walks the Chrome source, looking for calls to
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 number_of_files_total = number_of_files_total + 1 476 number_of_files_total = number_of_files_total + 1
477 477
478 finder = ActionNameFinder(path, open(path).read()) 478 finder = ActionNameFinder(path, open(path).read())
479 while True: 479 while True:
480 try: 480 try:
481 action_name = finder.FindNextAction() 481 action_name = finder.FindNextAction()
482 if not action_name: 482 if not action_name:
483 break 483 break
484 actions.add(action_name) 484 actions.add(action_name)
485 except InvalidStatementException, e: 485 except InvalidStatementException, e:
486 log.warning(str(e)) 486 logging.warning(str(e))
487 487
488 line_number = 0 488 line_number = 0
489 for line in open(path): 489 for line in open(path):
490 line_number = line_number + 1 490 line_number = line_number + 1
491 if COMPUTED_ACTION_RE.search(line): 491 if COMPUTED_ACTION_RE.search(line):
492 # Warn if this file shouldn't be calling RecordComputedAction. 492 # Warn if this file shouldn't be calling RecordComputedAction.
493 if os.path.basename(path) not in KNOWN_COMPUTED_USERS: 493 if os.path.basename(path) not in KNOWN_COMPUTED_USERS:
494 log.warning('%s has RecordComputedAction statement on line %d' % 494 logging.warning('%s has RecordComputedAction statement on line %d' %
495 (path, line_number)) 495 (path, line_number))
496 496
497 class WebUIActionsParser(HTMLParser): 497 class WebUIActionsParser(HTMLParser):
498 """Parses an HTML file, looking for all tags with a 'metric' attribute. 498 """Parses an HTML file, looking for all tags with a 'metric' attribute.
499 Adds user actions corresponding to any metrics found. 499 Adds user actions corresponding to any metrics found.
500 500
501 Arguments: 501 Arguments:
502 actions: set of actions to add to 502 actions: set of actions to add to
503 """ 503 """
504 def __init__(self, actions): 504 def __init__(self, actions):
505 HTMLParser.__init__(self) 505 HTMLParser.__init__(self)
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 868
869 with open(actions_xml_path, 'wb') as f: 869 with open(actions_xml_path, 'wb') as f:
870 f.write(pretty) 870 f.write(pretty)
871 print ('Updated %s. Don\'t forget to add it to your changelist' % 871 print ('Updated %s. Don\'t forget to add it to your changelist' %
872 actions_xml_path) 872 actions_xml_path)
873 return 0 873 return 0
874 874
875 875
876 if '__main__' == __name__: 876 if '__main__' == __name__:
877 sys.exit(main(sys.argv)) 877 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698