mirror of
https://github.com/kennethreitz-archive/vaincheese.git
synced 2026-06-05 07:16:14 +00:00
Added a func total_downloads to check all possible package name like flask, Flask, FLask etc. When package name = flask, returned download count is 0. The new function will try create all possible package name from flask to FLASK with incremental capitalization of each character
This commit is contained in:
+14
-2
@@ -33,17 +33,29 @@ def index():
|
||||
return jsonify(d)
|
||||
|
||||
|
||||
def total_downloads(package):
|
||||
count = downloads_total(package)
|
||||
package = package.swapcase() if package.isupper() else package
|
||||
while not count:
|
||||
for pos, value in enumerate(package):
|
||||
temp_package = package[:pos].swapcase() + package[pos:]
|
||||
count = downloads_total(temp_package)
|
||||
if count:
|
||||
return count
|
||||
else:
|
||||
return count
|
||||
|
||||
@app.route('/pypi/<package>')
|
||||
@cache.memoize(timeout=6*60*60)
|
||||
def package_stats(package):
|
||||
|
||||
d = {
|
||||
'package': package,
|
||||
'downloads': downloads_total(package)
|
||||
'downloads': total_downloads(package)
|
||||
}
|
||||
|
||||
return jsonify(d)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
||||
app.run()
|
||||
|
||||
Reference in New Issue
Block a user