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

Side by Side Diff: tools/dom/scripts/monitored.py

Issue 18277003: "Reverting 24655" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « tools/dom/scripts/logging.conf ('k') | tools/dom/scripts/systemhtml.py » ('j') | 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/python 1 #!/usr/bin/python
2 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
3 # for details. All rights reserved. Use of this source code is governed by a 3 # for details. All rights reserved. Use of this source code is governed by a
4 # BSD-style license that can be found in the LICENSE file. 4 # BSD-style license that can be found in the LICENSE file.
5 5
6 """This module provides maps and sets that report unused elements.""" 6 """This module provides maps and sets that report unused elements."""
7 7
8 _monitored_values = [] 8 _monitored_values = []
9 9
10 10
(...skipping 28 matching lines...) Expand all
39 self._used_keys.add(key) 39 self._used_keys.add(key)
40 return key in self._map 40 return key in self._map
41 41
42 def __iter__(self): 42 def __iter__(self):
43 return self._map.__iter__() 43 return self._map.__iter__()
44 44
45 def get(self, key, default=None): 45 def get(self, key, default=None):
46 self._used_keys.add(key) 46 self._used_keys.add(key)
47 return self._map.get(key, default) 47 return self._map.get(key, default)
48 48
49 def keys(self):
50 return self._map.keys()
51
52 def CheckUsage(self): 49 def CheckUsage(self):
53 for v in sorted(self._map.keys()): 50 for v in sorted(self._map.keys()):
54 if v not in self._used_keys: 51 if v not in self._used_keys:
55 print "dict '%s' has unused key '%s'" % (self.name, v) 52 print "dict '%s' has unused key '%s'" % (self.name, v)
56 53
57 54
58 class Set(MonitoredCollection): 55 class Set(MonitoredCollection):
59 """Wrapper for a set that reports unused keys.""" 56 """Wrapper for a set that reports unused keys."""
60 57
61 def __init__(self, name, a_set, dart2jsOnly=False): 58 def __init__(self, name, a_set, dart2jsOnly=False):
62 super(Set, self).__init__(name, dart2jsOnly) 59 super(Set, self).__init__(name, dart2jsOnly)
63 self._set = a_set 60 self._set = a_set
64 61
65 def __contains__(self, key): 62 def __contains__(self, key):
66 self._used_keys.add(key) 63 self._used_keys.add(key)
67 return key in self._set 64 return key in self._set
68 65
69 def __iter__(self): 66 def __iter__(self):
70 return self._set.__iter__() 67 return self._set.__iter__()
71 68
72 def add(self, key): 69 def add(self, key):
73 self._set += [key] 70 self._set += [key]
74 71
75 def CheckUsage(self): 72 def CheckUsage(self):
76 for v in sorted(self._set): 73 for v in sorted(self._set):
77 if v not in self._used_keys: 74 if v not in self._used_keys:
78 print "set '%s' has unused key '%s'" % (self.name, v) 75 print "set '%s' has unused key '%s'" % (self.name, v)
OLDNEW
« no previous file with comments | « tools/dom/scripts/logging.conf ('k') | tools/dom/scripts/systemhtml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698