diff --git a/pubs/bibstruct.py b/pubs/bibstruct.py index c3e481e..c8f942a 100644 --- a/pubs/bibstruct.py +++ b/pubs/bibstruct.py @@ -1,7 +1,7 @@ import unicodedata import re -from .p3 import ustr +from .p3 import ustr, unichr # citekey stuff diff --git a/pubs/content.py b/pubs/content.py index 8b89b31..f113f9b 100644 --- a/pubs/content.py +++ b/pubs/content.py @@ -3,9 +3,7 @@ import subprocess import tempfile import shutil -import urlparse -import httplib -import urllib2 +from .p3 import urlparse, HTTPConnection, urlopen # files i/o @@ -62,7 +60,7 @@ def system_path(path): # dealing with formatless content def content_type(path): - parsed = urlparse.urlparse(path) + parsed = urlparse(path) if parsed.scheme == 'http': return 'url' else: @@ -70,8 +68,8 @@ def content_type(path): def url_exists(url): - parsed = urlparse.urlparse(url) - conn = httplib.HTTPConnection(parsed.netloc) + parsed = urlparse(url) + conn = HTTPConnection(parsed.netloc) conn.request('HEAD', parsed.path) response = conn.getresponse() conn.close() diff --git a/pubs/filebroker.py b/pubs/filebroker.py index fe1218c..73b3ad6 100644 --- a/pubs/filebroker.py +++ b/pubs/filebroker.py @@ -1,6 +1,6 @@ import os import re -import urlparse +from .p3 import urlparse from .content import (check_file, check_directory, read_file, write_file, system_path, check_content, content_type, get_content) @@ -122,7 +122,7 @@ class DocBroker(object): def in_docsdir(self, docpath): try: - parsed = urlparse.urlparse(docpath) + parsed = urlparse(docpath) except Exception: return False return parsed.scheme == self.scheme @@ -136,7 +136,7 @@ class DocBroker(object): Return absoluted paths of regular ones otherwise. """ if self.in_docsdir(docpath): - parsed = urlparse.urlparse(docpath) + parsed = urlparse(docpath) if parsed.path == '': docpath = os.path.join(self.docdir, parsed.netloc) else: diff --git a/pubs/p3.py b/pubs/p3.py index 4897960..ed9c406 100644 --- a/pubs/p3.py +++ b/pubs/p3.py @@ -5,11 +5,19 @@ if sys.version_info[0] == 2: import StringIO as io input = raw_input ustr = unicode + from urlparse import urlparse + from urllib2 import urlopen + from httplib import HTTPConnection else: import configparser import io ustr = str + from urllib.parse import urlparse + from urllib.request import urlopen + from http.client import HTTPConnection + unichr = chr configparser = configparser io = io input = input +unichr = unichr