Skip to content

Commit

Permalink
Add wheel/python-version/python-implementation/status badage for PyPI.
Browse files Browse the repository at this point in the history
To replace the pypipins: badges/pypipins#39
  • Loading branch information
tonyseek committed Jun 7, 2015
1 parent 4cc9ca9 commit 961e898
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
16 changes: 16 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,22 @@ <h3 id="miscellaneous"> Miscellaneous </h3>
<td><img src='https://img.shields.io/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='https://img.shields.io/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='https://img.shields.io/pypi/py_versions/Django.svg' alt=''/></td>
<td><code>https://img.shields.io/pypi/py_versions/Django.svg</code></td>
</tr>
<tr><th data-keywords='python'> PyPI: </th>
<td><img src='https://img.shields.io/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='https://img.shields.io/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='https://img.shields.io/hexpm/l/plug.svg' alt=''/></td>
<td><code>https://img.shields.io/hexpm/l/plug.svg</code></td>
Expand Down
67 changes: 67 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
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) {
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) {
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';
Expand Down

0 comments on commit 961e898

Please sign in to comment.