aclark4life / vanity

Get package download statistics from PyPI
GNU General Public License v2.0
66 stars 14 forks source link

Case insensitive project names and support for counting all release files. #2

Closed JNRowe closed 12 years ago

JNRowe commented 12 years ago

The first commit makes vanity count all release files in its totals, which I find very useful for projects that host multiple archive formats or eggs. For example, Twisted reports 58349 downloads if only the first file is counted, and 161768 downloads if all files are included.

The second commit is a potential fix for #1. A bit nasty, but makes vanity django or vanity twisted work ;)

Thanks,

James

JNRowe commented 12 years ago

[To cover all bases]

If the "first file only" behaviour is the desired result, would you be open to optional support for all files counting?

aclark4life commented 12 years ago

Thanks! Are you sure you are counting right? With your change I get:

Package Pillow has been downloaded 16913 times!

Up from:

Package Pillow has been downloaded 13931 times!

Which does not sound right (I'd expect something like 13931 + 400 or so binaries added in 1.7.5)

Or am I missing something?

JNRowe commented 12 years ago

The previous method counted only the first download file in the list returned by PyPI, which is not necessarily the source package. So in the Pillow 1.7.5 case it was counting Pillow-1.7.5-py2.4-win32.egg. The ~3k difference is the other eggs and the zip source:

[{'comment_text': '',
  'downloads': 76,
  'filename': 'Pillow-1.7.5-py2.4-win32.egg',
  'has_sig': False,
  'md5_digest': '2cd17421aa7493ef4ca134b48ae48746',
  'packagetype': 'bdist_egg',
  'python_version': '2.4',
  'size': 817794,
  'upload_time': <DateTime '20110908T03:43:42' at 2722050>,
  'url': 'http://pypi.python.org/packages/2.4/P/Pillow/Pillow-1.7.5-py2.4-win32.egg'},
 {'comment_text': '',
  'downloads': 82,
  'filename': 'Pillow-1.7.5-py2.5-win32.egg',
  'has_sig': False,
  'md5_digest': '18f99878682bd561e23f5e9b7bb172c3',
  'packagetype': 'bdist_egg',
  'python_version': '2.5',
  'size': 814919,
  'upload_time': <DateTime '20110908T03:43:17' at 2722128>,
  'url': 'http://pypi.python.org/packages/2.5/P/Pillow/Pillow-1.7.5-py2.5-win32.egg'},
 {'comment_text': '',
  'downloads': 107,
  'filename': 'Pillow-1.7.5-py2.6-win32.egg',
  'has_sig': False,
  'md5_digest': '8915394ea21470b01d3d0a9e88ddfa31',
  'packagetype': 'bdist_egg',
  'python_version': '2.6',
  'size': 822807,
  'upload_time': <DateTime '20110908T03:38:14' at 2722200>,
  'url': 'http://pypi.python.org/packages/2.6/P/Pillow/Pillow-1.7.5-py2.6-win32.egg'},
 {'comment_text': '',
  'downloads': 113,
  'filename': 'Pillow-1.7.5-py2.7-win32.egg',
  'has_sig': False,
  'md5_digest': 'eaad5079b449e0024173faf1ff510372',
  'packagetype': 'bdist_egg',
  'python_version': '2.7',
  'size': 822377,
  'upload_time': <DateTime '20110908T03:37:53' at 27222d8>,
  'url': 'http://pypi.python.org/packages/2.7/P/Pillow/Pillow-1.7.5-py2.7-win32.egg'},
 {'comment_text': '',
  'downloads': 2680,
  'filename': 'Pillow-1.7.5.zip',
  'has_sig': False,
  'md5_digest': 'd0c79286f62fa83c15b8d19e693ad4f9',
  'packagetype': 'sdist',
  'python_version': 'source',
  'size': 637654,
  'upload_time': <DateTime '20110907T20:33:54' at 2722368>,
  'url': 'http://pypi.python.org/packages/source/P/Pillow/Pillow-1.7.5.zip'}]

I could have been much clearer in my original explanation, and I apologise for that ;)

aclark4life commented 12 years ago

Ah! OK So basically this is a bug fix too, got it.

aclark4life commented 12 years ago

Fixed in http://pypi.python.org/pypi/vanity/1.1.0