From 6fb0335269e9d9dbd79c2f4cb020cd9a6b03313a Mon Sep 17 00:00:00 2001 From: Honza Javorek Date: Wed, 25 Sep 2013 11:39:29 +0200 Subject: [PATCH] Attempt to be compilant with Python 3. --- pelican/contents.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pelican/contents.py b/pelican/contents.py index 83fbad8f..dbc33716 100644 --- a/pelican/contents.py +++ b/pelican/contents.py @@ -5,12 +5,16 @@ import six import copy import locale import logging -import urlparse import functools import os import re import sys +try: + from urlparse import urlparse, urlunparse +except ImportError: + from urllib.parse import urlparse, urlunparse + from datetime import datetime @@ -195,7 +199,7 @@ class Content(object): def replacer(m): what = m.group('what') - value = urlparse.urlparse(m.group('value')) + value = urlparse(m.group('value')) path = value.path origin = m.group('path') @@ -224,7 +228,7 @@ class Content(object): # keep all other parts, such as query, fragment, etc. parts = list(value) parts[2] = origin - origin = urlparse.urlunparse(parts) + origin = urlunparse(parts) return ''.join((m.group('markup'), m.group('quote'), origin, m.group('quote')))