Created
April 23, 2014 04:32
-
-
Save atdt/11202803 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import collections | |
records = [json.loads(line) for line in open('deprecated-js.json')] | |
def iter_modules(): | |
for record in records: | |
for module in record.get('modules', ()): | |
yield module | |
counter = collections.Counter(module for module in iter_modules() if 'gadget' in module) # just the gadgets | |
worst_offenders = {module for module, hits in counter.most_common(10)} | |
offenses = {module: set() for module in worst_offenders} | |
for record in records: | |
for module in worst_offenders & set(record.get('modules', ())): | |
offenses[module].add(record['method']) | |
print '-- gadget hall of shame --' | |
for rank, (module, hits) in enumerate(counter.most_common(10)): | |
print 'rank: #%d' % (rank + 1) | |
print 'module: %s' % module | |
print 'offenses: %s' % offenses[module] | |
print '---' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- gadget hall of shame -- | |
rank: #1 | |
module: ext.gadget.MonobookToolbarStandard | |
offenses: set([u'insertTags', u'addOnloadHook', u'mwCustomEditButtons']) | |
--- | |
rank: #2 | |
module: ext.gadget.mySandbox | |
offenses: set([u'addPortletLink', u'wikiGetlink']) | |
--- | |
rank: #3 | |
module: ext.gadget.directLinkToCommons | |
offenses: set([u'wikiGetlink']) | |
--- | |
rank: #4 | |
module: ext.gadget.Twinkle | |
offenses: set([u'wikiGetlink', u'jsMsg', u'addPortletLink', u'getElementsByClassName', u'hasClass', u'sajax_init_object']) | |
--- | |
rank: #5 | |
module: ext.gadget.a-commons-directo | |
offenses: set([u'wikiGetlink']) | |
--- | |
rank: #6 | |
module: ext.gadget.ProveIt | |
offenses: set([u'addOnloadHook']) | |
--- | |
rank: #7 | |
module: ext.gadget.HotCat | |
offenses: set([u'is_opera', u'sajax_init_object', u'getElementsByClassName', u'is_safari', u'ie6_bugs', u'addOnloadHook']) | |
--- | |
rank: #8 | |
module: ext.gadget.Direct-link-to-Commons | |
offenses: set([u'wikiGetlink']) | |
--- | |
rank: #9 | |
module: ext.gadget.edittop | |
offenses: set([u'wikiGetlink', u'getElementsByClassName']) | |
--- | |
rank: #10 | |
module: ext.gadget.urldecoder | |
offenses: set([u'mwCustomEditButtons']) | |
--- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment