Advertisement
Guest User

bplugs.py

a guest
Jan 2nd, 2013
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. import json
  2. import datetime
  3. import pymongo
  4.  
  5. conn = pymongo.MongoClient()
  6. db = conn.bukget
  7. plugins = db.plugins
  8.  
  9. bplugs = []
  10. for plugin in plugins.find():
  11.     versions = []
  12.     vcount = 0
  13.     for version in plugin['versions']:
  14.         vcount += 1
  15.         if version['version'] not in versions: versions.append(version['version'])
  16.     if vcount > 2 and len(versions) == 1: bplugs.append({
  17.         'name': plugin['slug'],
  18.         'static_version': versions[0],
  19.         'num_versions': vcount,
  20.         'last_update': datetime.datetime.fromtimestamp(plugin['versions'][0]['date']).strftime('%D'),
  21.         'authors': plugin['authors']
  22.         })
  23. print 'Number of Offending Plugins: %s' % len(bplugs)
  24. with open('bplugs.json', 'w') as bfile:
  25.     bfile.write(json.dumps(bplugs))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement