Commit 7efd5698 authored by alexandre's avatar alexandre

Py3 compatibility

parent dfe215e1
......@@ -90,7 +90,7 @@ class AASniffer(object):
class AAApp(object):
>>> app = AAApp()
>>> app.index('')
>>> app.index('')
def __init__(self, conf=conf):
self.conf = conf
......@@ -168,11 +168,11 @@ class AAApp(object):
# print(self.graph.serialize(format='nquads'))
from sniffers.http import HttpSniffer
from sniffers.html import HtmlSniffer
from sniffers.turtle import TurtleSniffer
from sniffers.image import ImageSniffer
from sniffers.ogg import OggSniffer
from sniffers.rdf import RDFSniffer
from sniffers.wav import WavSniffer
from import YoutubeSniffer
from aasniff.sniffers.http import HttpSniffer
from aasniff.sniffers.html import HtmlSniffer
from aasniff.sniffers.turtle import TurtleSniffer
from aasniff.sniffers.image import ImageSniffer
from aasniff.sniffers.ogg import OggSniffer
from aasniff.sniffers.rdf import RDFSniffer
from aasniff.sniffers.wav import WavSniffer
from import YoutubeSniffer
......@@ -20,7 +20,7 @@ class HttpSniffer(AASniffer):
# FIXME: there should be a way to avoid doing a second request.
# See <>
request = requests.get(self.request.url, stream=True)
mime = magic.from_buffer(request.iter_content(1024).next(), mime=True)
mime = magic.from_buffer(next(request.iter_content(1024)), mime=True)
DCT = Namespace('')
HDR = Namespace('')
......@@ -28,7 +28,7 @@ class HttpSniffer(AASniffer):
triples = [(subject, DCT['format'], Literal(mime))]
for key, value in self.request.headers.items():
for key, value in list(self.request.headers.items()):
triples.append((subject, HDR[key.lower()], Literal(value)))
return triples
......@@ -5,8 +5,8 @@ from .. import sniffer, AASniffer
try: import simplejson as json
except ImportError: import json
try: from cStringIO import StringIO
except: from StringIO import StringIO
try: from io import StringIO
except: from io import StringIO
from rdflib import Namespace, URIRef, Literal
......@@ -30,7 +30,7 @@ class WavSniffer(AASniffer):
def sniff(self):
print("sniffed an wav file")
request = requests.get(self.request.url, stream=True)
head = request.iter_content(1024).next()
head = next(request.iter_content(1024))
output = StringIO(head)
f =, 'r')
duration = (1.0 * f.getnframes ()) / f.getframerate ()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment