Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Commit

Permalink
Use UTF-8 and get tests running under Python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
davedoesdev committed Nov 25, 2015
1 parent 69c933a commit 9d33295
Show file tree
Hide file tree
Showing 24 changed files with 1,032 additions and 638 deletions.
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.pyc
node_modules/
dist/
.coverage/
build/
python_jwt.egg-info/
/node_modules
/dist
/.coverage
/build
/python_jwt.egg-info
/python
10 changes: 7 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
sudo: false
language: python
python:
- "2.7"
- "3.4"
node_js:
- "0.12"
before_install:
- sudo apt-get update
- sudo apt-get install libevent-dev
- make node_deps
addons:
apt:
packages:
- libevent-dev
install:
- pip install -r requirements.txt
- pip install --user -r requirements.txt
script:
- ( while true; do echo keep alive!; sleep 60; done ) &
- make travis_test
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Module for generating and verifying [JSON Web Tokens](http://self-issued.info/do
- Uses [python-jws](https://github.com/brianloveswords/python-jws) to do the heavy lifting.
- Supports [__RS256__, __RS384__, __RS512__](http://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-14#section-3.3), [__PS256__, __PS384__, __PS512__](http://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-14#section-3.5), [__HS256__, __HS384__, __HS512__](http://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-14#section-3.2) and [__none__](http://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-14#section-3.6) signature algorithms.
- Unit tests, including tests for interoperability with [node-jsjws](https://github.com/davedoesdev/node-jsjws).
- Tentative support for Python 3.4. Although the examples below work, the unit tests are blocked on [PyVows](https://github.com/heynemann/pyvows/issues/23) and [gevent](https://github.com/gevent/gevent/issues/38) support for Python 3.4. **Note:** [generate_jwt](http://rawgit.davedoesdev.com/davedoesdev/python-jwt/master/docs/_build/html/index.html#jwt.generate_jwt) now returns the token as a Unicode string, even on Python 2.7.
- Supports Python 3.4. **Note:** [generate_jwt](http://rawgit.davedoesdev.com/davedoesdev/python-jwt/master/docs/_build/html/index.html#jwt.generate_jwt) returns the token as a Unicode string, even on Python 2.7.

Example:

Expand Down
8 changes: 2 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@ Tokens <http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html>`__.
signature algorithms.
- Unit tests, including tests for interoperability with
`node-jsjws <https://github.com/davedoesdev/node-jsjws>`__.
- Tentative support for Python 3.4. Although the examples below work,
the unit tests are blocked on
`PyVows <https://github.com/heynemann/pyvows/issues/23>`__ and
`gevent <https://github.com/gevent/gevent/issues/38>`__ support for
Python 3.4. **Note:**
- Supports Python 3.4. **Note:**
`generate\_jwt <http://rawgit.davedoesdev.com/davedoesdev/python-jwt/master/docs/_build/html/index.html#jwt.generate_jwt>`__
now returns the token as a Unicode string, even on Python 2.7.
returns the token as a Unicode string, even on Python 2.7.

Example:

Expand Down
123 changes: 64 additions & 59 deletions coverage/coverage.xml
Original file line number Diff line number Diff line change
@@ -1,83 +1,88 @@
<?xml version="1.0" ?>
<!DOCTYPE coverage
SYSTEM 'http://cobertura.sourceforge.net/xml/coverage-03.dtd'>
<coverage branch-rate="0.7" line-rate="0.8841" timestamp="1426154666580" version="3.7.1">
<!-- Generated by coverage.py: http://nedbatchelder.com/code/coverage -->
<coverage branch-rate="0.7273" line-rate="0.8873" timestamp="1448447048383" version="4.0.3">
<!-- Generated by coverage.py: https://coverage.readthedocs.org -->
<!-- Based on https://raw.githubusercontent.com/cobertura/web/f0366e5e2cf18f111cbd61fc34ef720a6584ba02/htdocs/xml/coverage-03.dtd -->
<sources>
<source>/home/david/Private/hub/common/python-jwt</source>
<source>/home/david/Private/hub/common/python-jwt/jwt</source>
</sources>
<packages>
<package branch-rate="0.7" complexity="0" line-rate="0.8841" name="">
<package branch-rate="0.7273" complexity="0" line-rate="0.8873" name="jwt">
<classes>
<class branch-rate="0.7" complexity="0" filename="jwt/__init__.py" line-rate="0.8841" name="jwt/__init__">
<class branch-rate="0.7273" complexity="0" filename="jwt/__init__.py" line-rate="0.8873" name="__init__.py">
<methods/>
<lines>
<line hits="1" number="5"/>
<line hits="1" number="6"/>
<line hits="1" number="7"/>
<line hits="1" number="8"/>
<line hits="1" number="9"/>
<line hits="1" number="11"/>
<line hits="1" number="14"/>
<line hits="1" number="16"/>
<line hits="1" number="52"/>
<line hits="1" number="57"/>
<line hits="1" number="59"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="61"/>
<line hits="1" number="62"/>
<line hits="1" number="64"/>
<line hits="1" number="65"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="67"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="11"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="15"/>
<line hits="1" number="20"/>
<line hits="1" number="23"/>
<line hits="1" number="25"/>
<line hits="1" number="61"/>
<line hits="1" number="66"/>
<line hits="1" number="68"/>
<line branch="true" condition-coverage="50% (1/2)" hits="1" number="69"/>
<line hits="1" number="70"/>
<line hits="1" number="72"/>
<line hits="1" number="80"/>
<line hits="1" number="117"/>
<line hits="1" number="119"/>
<line hits="1" number="120"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="122"/>
<line hits="1" number="123"/>
<line hits="1" number="125"/>
<line branch="true" condition-coverage="50% (1/2)" hits="1" number="126"/>
<line hits="0" number="127"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="128"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="70"/>
<line hits="1" number="71"/>
<line hits="1" number="73"/>
<line hits="1" number="74"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="76"/>
<line hits="1" number="77"/>
<line branch="true" condition-coverage="50% (1/2)" hits="1" missing-branches="81" number="78"/>
<line hits="1" number="79"/>
<line hits="1" number="81"/>
<line hits="1" number="89"/>
<line hits="1" number="126"/>
<line hits="1" number="128"/>
<line hits="1" number="129"/>
<line hits="1" number="131"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="133"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="131"/>
<line hits="1" number="132"/>
<line hits="1" number="134"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="135"/>
<line hits="1" number="136"/>
<line branch="true" condition-coverage="50% (1/2)" hits="1" missing-branches="136" number="135"/>
<line hits="0" number="136"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="137"/>
<line hits="1" number="138"/>
<line hits="1" number="140"/>
<line hits="1" number="141"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="142"/>
<line hits="1" number="143"/>
<line branch="true" condition-coverage="50% (1/2)" hits="1" number="144"/>
<line branch="true" condition-coverage="0% (0/2)" hits="0" number="145"/>
<line hits="0" number="146"/>
<line branch="true" condition-coverage="50% (1/2)" hits="1" number="147"/>
<line hits="0" number="148"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="144"/>
<line hits="1" number="145"/>
<line hits="1" number="147"/>
<line hits="1" number="149"/>
<line hits="1" number="150"/>
<line branch="true" condition-coverage="50% (1/2)" hits="1" number="151"/>
<line branch="true" condition-coverage="0% (0/2)" hits="0" number="152"/>
<line hits="0" number="153"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="154"/>
<line hits="1" number="155"/>
<line hits="1" number="157"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="158"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="159"/>
<line hits="1" number="160"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="161"/>
<line hits="1" number="162"/>
<line hits="1" number="152"/>
<line branch="true" condition-coverage="50% (1/2)" hits="1" missing-branches="154" number="153"/>
<line branch="true" condition-coverage="0% (0/2)" hits="0" missing-branches="155,159" number="154"/>
<line hits="0" number="155"/>
<line branch="true" condition-coverage="50% (1/2)" hits="1" missing-branches="157" number="156"/>
<line hits="0" number="157"/>
<line hits="1" number="159"/>
<line branch="true" condition-coverage="50% (1/2)" hits="1" missing-branches="161" number="160"/>
<line branch="true" condition-coverage="0% (0/2)" hits="0" missing-branches="162,166" number="161"/>
<line hits="0" number="162"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="163"/>
<line hits="1" number="164"/>
<line branch="true" condition-coverage="50% (1/2)" hits="1" number="165"/>
<line branch="true" condition-coverage="0% (0/2)" hits="0" number="166"/>
<line hits="0" number="167"/>
<line hits="1" number="166"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="167"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="168"/>
<line hits="1" number="169"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="170"/>
<line hits="1" number="171"/>
<line hits="1" number="175"/>
<line hits="1" number="187"/>
<line hits="1" number="188"/>
<line hits="1" number="189"/>
<line hits="1" number="190"/>
<line hits="1" number="173"/>
<line branch="true" condition-coverage="50% (1/2)" hits="1" missing-branches="175" number="174"/>
<line branch="true" condition-coverage="0% (0/2)" hits="0" missing-branches="176,180" number="175"/>
<line hits="0" number="176"/>
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="177"/>
<line hits="1" number="178"/>
<line hits="1" number="180"/>
<line hits="1" number="184"/>
<line hits="1" number="196"/>
<line hits="1" number="197"/>
<line hits="1" number="198"/>
<line hits="1" number="199"/>
</lines>
</class>
</classes>
Expand Down
142 changes: 139 additions & 3 deletions coverage/html/coverage_html.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
// For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt

// Coverage.py HTML report browser code.
/*jslint browser: true, sloppy: true, vars: true, plusplus: true, maxerr: 50, indent: 4 */
/*global coverage: true, document, window, $ */

coverage = {};

// Find all the elements with shortkey_* class, and use them to assign a shotrtcut key.
// Find all the elements with shortkey_* class, and use them to assign a shortcut key.
coverage.assign_shortkeys = function () {
$("*[class*='shortkey_']").each(function (i, e) {
$.each($(e).attr("class").split(" "), function (i, c) {
Expand Down Expand Up @@ -35,6 +38,137 @@ coverage.wire_up_help_panel = function () {
});
};

// Create the events for the filter box.
coverage.wire_up_filter = function () {
// Cache elements.
var table = $("table.index");
var table_rows = table.find("tbody tr");
var table_row_names = table_rows.find("td.name a");
var no_rows = $("#no_rows");

// Create a duplicate table footer that we can modify with dynamic summed values.
var table_footer = $("table.index tfoot tr");
var table_dynamic_footer = table_footer.clone();
table_dynamic_footer.attr('class', 'total_dynamic hidden');
table_footer.after(table_dynamic_footer);

// Observe filter keyevents.
$("#filter").on("keyup change", $.debounce(150, function (event) {
var filter_value = $(this).val();

if (filter_value === "") {
// Filter box is empty, remove all filtering.
table_rows.removeClass("hidden");

// Show standard footer, hide dynamic footer.
table_footer.removeClass("hidden");
table_dynamic_footer.addClass("hidden");

// Hide placeholder, show table.
if (no_rows.length > 0) {
no_rows.hide();
}
table.show();

}
else {
// Filter table items by value.
var hide = $([]);
var show = $([]);

// Compile elements to hide / show.
$.each(table_row_names, function () {
var element = $(this).parents("tr");

if ($(this).text().indexOf(filter_value) === -1) {
// hide
hide = hide.add(element);
}
else {
// show
show = show.add(element);
}
});

// Perform DOM manipulation.
hide.addClass("hidden");
show.removeClass("hidden");

// Show placeholder if no rows will be displayed.
if (no_rows.length > 0) {
if (show.length === 0) {
// Show placeholder, hide table.
no_rows.show();
table.hide();
}
else {
// Hide placeholder, show table.
no_rows.hide();
table.show();
}
}

// Manage dynamic header:
if (hide.length > 0) {
// Calculate new dynamic sum values based on visible rows.
for (var column = 2; column < 20; column++) {
// Calculate summed value.
var cells = table_rows.find('td:nth-child(' + column + ')');
if (!cells.length) {
// No more columns...!
break;
}

var sum = 0, numer = 0, denom = 0;
$.each(cells.filter(':visible'), function () {
var ratio = $(this).data("ratio");
if (ratio) {
var splitted = ratio.split(" ");
numer += parseInt(splitted[0], 10);
denom += parseInt(splitted[1], 10);
}
else {
sum += parseInt(this.innerHTML, 10);
}
});

// Get footer cell element.
var footer_cell = table_dynamic_footer.find('td:nth-child(' + column + ')');

// Set value into dynamic footer cell element.
if (cells[0].innerHTML.indexOf('%') > -1) {
// Percentage columns use the numerator and denominator,
// and adapt to the number of decimal places.
var match = /\.([0-9]+)/.exec(cells[0].innerHTML);
var places = 0;
if (match) {
places = match[1].length;
}
var pct = numer * 100 / denom;
footer_cell.text(pct.toFixed(places) + '%');
}
else {
footer_cell.text(sum);
}
}

// Hide standard footer, show dynamic footer.
table_footer.addClass("hidden");
table_dynamic_footer.removeClass("hidden");
}
else {
// Show standard footer, hide dynamic footer.
table_footer.removeClass("hidden");
table_dynamic_footer.addClass("hidden");
}
}
}));

// Trigger change event on setup, to force filter on page refresh
// (filter value may still be present).
$("#filter").trigger("change");
};

// Loaded on index.html
coverage.index_ready = function ($) {
// Look for a cookie containing previous sort settings:
Expand Down Expand Up @@ -95,6 +229,7 @@ coverage.index_ready = function ($) {

coverage.assign_shortkeys();
coverage.wire_up_help_panel();
coverage.wire_up_filter();

// Watch for page unload events so we can save the final sort settings:
$(window).unload(function () {
Expand Down Expand Up @@ -187,12 +322,13 @@ coverage.to_next_chunk = function () {

// Find the start of the next colored chunk.
var probe = c.sel_end;
var color, probe_line;
while (true) {
var probe_line = c.line_elt(probe);
probe_line = c.line_elt(probe);
if (probe_line.length === 0) {
return;
}
var color = probe_line.css("background-color");
color = probe_line.css("background-color");
if (!c.is_transparent(color)) {
break;
}
Expand Down
Loading

0 comments on commit 9d33295

Please sign in to comment.