-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add wheel/python-version/python-implementation/status badage for PyPI. #465
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1481,6 +1481,73 @@ cache(function(data, match, sendBadge, request) { | |
badgeData.colorscheme = 'blue'; | ||
} | ||
sendBadge(format, badgeData); | ||
} else if (info == 'wheel') { | ||
var releases = data.releases[data.info.version]; | ||
var hasWheel = false; | ||
for (var i in releases) { | ||
if (releases[i].packagetype == 'wheel' || | ||
releases[i].packagetype == 'bdist_wheel') { | ||
hasWheel = true; | ||
break; | ||
} | ||
} | ||
badgeData.text[0] = 'wheel'; | ||
badgeData.text[1] = hasWheel ? 'yes' : 'no'; | ||
badgeData.colorscheme = hasWheel ? 'brightgreen' : 'red'; | ||
sendBadge(format, badgeData); | ||
} else if (info == 'py_versions') { | ||
var versions = []; | ||
var pattern = /^Programming Language \:\: Python \:\: (\d\.\d)$/; | ||
for (var i in data.info.classifiers) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you use a regular loop here too? |
||
var matched = pattern.exec(data.info.classifiers[i]); | ||
if (matched && matched[1]) { | ||
versions.push(matched[1]); | ||
} | ||
} | ||
if (!versions.length) { | ||
versions.push('not found'); | ||
} | ||
badgeData.text[0] = 'python'; | ||
badgeData.text[1] = versions.sort().join(', '); | ||
badgeData.colorscheme = 'blue'; | ||
sendBadge(format, badgeData); | ||
} else if (info == 'implementation') { | ||
var implementations = []; | ||
var pattern = /^Programming Language \:\: Python \:\: Implementation \:\: (\S+)$/; | ||
for (var i in data.info.classifiers) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you use a regular loop here, please? for (var i = 0; i < data.info.classifiers.length; i++) {
…
} (Yes, I agree, JS is ugly compared to Python ☺.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay. |
||
var matched = pattern.exec(data.info.classifiers[i]); | ||
if (matched && matched[1]) { | ||
implementations.push(matched[1].toLowerCase()); | ||
} | ||
} | ||
if (!implementations.length) { | ||
implementations.push('cpython'); // assume CPython | ||
} | ||
badgeData.text[0] = 'implementation'; | ||
badgeData.text[1] = implementations.sort().join(', '); | ||
badgeData.colorscheme = 'blue'; | ||
sendBadge(format, badgeData); | ||
} else if (info == 'status') { | ||
var pattern = /^Development Status \:\: ([1-7]) - (\S+)$/; | ||
var statusColors = { | ||
'1': 'red', '2': 'red', '3': 'red', '4': 'yellow', | ||
'5': 'brightgreen', '6': 'brightgreen', '7': 'red'}; | ||
var statusCode = '1', statusText = 'unknown'; | ||
for (var i in data.info.classifiers) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, and here as well. |
||
var matched = pattern.exec(data.info.classifiers[i]); | ||
if (matched && matched[1] && matched[2]) { | ||
statusCode = matched[1]; | ||
statusText = matched[2].toLowerCase().replace('-', '--'); | ||
if (statusText == 'production/stable') { | ||
statusText = 'stable'; | ||
} | ||
break; | ||
} | ||
} | ||
badgeData.text[0] = 'status'; | ||
badgeData.text[1] = statusText; | ||
badgeData.colorscheme = statusColors[statusCode]; | ||
sendBadge(format, badgeData); | ||
} | ||
} catch(e) { | ||
badgeData.text[1] = 'invalid'; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -518,6 +518,22 @@ <h3 id="miscellaneous"> Miscellaneous </h3> | |
<td><img src='/pypi/l/Django.svg' alt=''/></td> | ||
<td><code>https://img.shields.io/pypi/l/Django.svg</code></td> | ||
</tr> | ||
<tr><th data-keywords='python'> PyPI: </th> | ||
<td><img src='/pypi/wheel/Django.svg' alt=''/></td> | ||
<td><code>https://img.shields.io/pypi/wheel/Django.svg</code></td> | ||
</tr> | ||
<tr><th data-keywords='python'> PyPI: </th> | ||
<td><img src='/pypi/py_versions/Django.svg' alt=''/></td> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are using (I have a personal preference to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sorry. I forgot it. It will be fixed :-) |
||
<td><code>https://img.shields.io/pypi/py_versions/Django.svg</code></td> | ||
</tr> | ||
<tr><th data-keywords='python'> PyPI: </th> | ||
<td><img src='/pypi/implementation/Django.svg' alt=''/></td> | ||
<td><code>https://img.shields.io/pypi/implementation/Django.svg</code></td> | ||
</tr> | ||
<tr><th data-keywords='python'> PyPI: </th> | ||
<td><img src='/pypi/status/Django.svg' alt=''/></td> | ||
<td><code>https://img.shields.io/pypi/status/Django.svg</code></td> | ||
</tr> | ||
<tr><th> Hex.pm: </th> | ||
<td><img src='/hexpm/l/plug.svg' alt=''/></td> | ||
<td><code>https://img.shields.io/hexpm/l/plug.svg</code></td> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally, there.