Skip to content

Commit

Permalink
replaced future library with six for py3 support fixes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
johnwheeler committed Jun 2, 2016
1 parent 37c5194 commit 810e16a
Show file tree
Hide file tree
Showing 17 changed files with 13 additions and 20 deletions.
9 changes: 3 additions & 6 deletions flask_ask/verifier.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
from future.standard_library import install_aliases
install_aliases()

import os
import urllib.request, urllib.error, urllib.parse
import base64
import posixpath
from urllib.parse import urlparse
from datetime import datetime
from six.moves.urllib.parse import urlparse
from six.moves.urllib.request import urlopen

from OpenSSL import crypto

Expand All @@ -19,7 +16,7 @@ class VerificationError(Exception): pass
def load_certificate(cert_url):
if not _valid_certificate_url(cert_url):
raise VerificationError("Certificate URL verification failed")
cert_data = urllib.request.urlopen(cert_url).read()
cert_data = urlopen(cert_url).read()
cert = crypto.load_certificate(crypto.FILETYPE_PEM, cert_data)
if not _valid_certificate(cert):
raise VerificationError("Certificate verification failed")
Expand Down
11 changes: 5 additions & 6 deletions samples/historybuff/historybuff.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from future.standard_library import install_aliases
install_aliases()

import logging
import urllib.request, urllib.error, urllib.parse
import re
from six.moves.urllib.request import urlopen


from flask import Flask
Expand Down Expand Up @@ -107,14 +104,16 @@ def session_ended():

def _get_json_events_from_wikipedia(month, date):
url = "{}{}_{}".format(URL_PREFIX, month, date)
data = urllib.request.urlopen(url).read()
data = urlopen(url).read().decode('utf-8')
return _parse_json(data)


def _parse_json(text):
events = []
try:
text = text[text.index("\\nEvents\\n") + SIZE_OF_EVENTS: text.index("\\n\\n\\nBirths")];
slice_start = text.index("\\nEvents\\n") + SIZE_OF_EVENTS
slice_end = text.index("\\n\\n\\nBirths")
text = text[slice_start:slice_end];
except ValueError:
return events
start_index = end_index = 0
Expand Down
9 changes: 3 additions & 6 deletions samples/tidepooler/tidepooler.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
from future.standard_library import install_aliases
install_aliases()

import os
import logging
import datetime
import urllib.request, urllib.error, urllib.parse
import math
import re
from urllib.parse import urlencode
from six.moves.urllib.request import urlopen
from six.moves.urllib.parse import urlencode

import aniso8601
from flask import Flask, json, render_template
Expand Down Expand Up @@ -241,7 +238,7 @@ def _make_tide_request(city, date):
noaa_api_params['begin_date'] = date.strftime('%Y%m%d')
noaa_api_params['range'] = 24
url = ENDPOINT + "?" + urlencode(noaa_api_params)
resp_body = urllib.request.urlopen(url).read()
resp_body = urlopen(url).read()
if len(resp_body) == 0:
statement_text = render_template('noaa_problem')
else:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name='Flask-Ask',
version='0.7.3',
version='0.7.4',
url='https://github.com/johnwheeler/flask-ask',
license='Apache 2.0',
author='John Wheeler',
Expand All @@ -25,7 +25,7 @@
'pyOpenSSL',
'PyYAML',
'aniso8601',
'future',
'six',
],
classifiers=[
'License :: OSI Approved :: Apache Software License',
Expand Down

0 comments on commit 810e16a

Please sign in to comment.