From 626d9df6c4fc2dabdd508eae1378d48c359d961b Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Sat, 20 Sep 2014 23:51:04 +0200 Subject: [PATCH] Add Python 3 compatibility. --- feedgen/entry.py | 5 +++-- feedgen/feed.py | 9 +++++---- setup.py | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/feedgen/entry.py b/feedgen/entry.py index b1763f1..00e4c94 100644 --- a/feedgen/entry.py +++ b/feedgen/entry.py @@ -13,6 +13,7 @@ from datetime import datetime import dateutil.parser import dateutil.tz from feedgen.util import ensure_format +from six import string_types class FeedEntry(object): @@ -282,7 +283,7 @@ class FeedEntry(object): :returns: Modification date as datetime.datetime ''' if not updated is None: - if isinstance(updated, basestring): + if isinstance(updated, string_types): updated = dateutil.parser.parse(updated) if not isinstance(updated, datetime): raise ValueError('Invalid datetime format') @@ -549,7 +550,7 @@ class FeedEntry(object): :returns: Creation date as datetime.datetime ''' if not published is None: - if isinstance(published, basestring): + if isinstance(published, string_types): published = dateutil.parser.parse(published) if not isinstance(published, datetime): raise ValueError('Invalid datetime format') diff --git a/feedgen/feed.py b/feedgen/feed.py index 9e3fc4c..bfe1717 100644 --- a/feedgen/feed.py +++ b/feedgen/feed.py @@ -17,6 +17,7 @@ from feedgen.entry import FeedEntry from feedgen.util import ensure_format import feedgen.version import sys +from six import string_types _feedgen_version = feedgen.version.version_str @@ -431,7 +432,7 @@ class FeedGenerator(object): :returns: Modification date as datetime.datetime ''' if not updated is None: - if isinstance(updated, basestring): + if isinstance(updated, string_types): updated = dateutil.parser.parse(updated) if not isinstance(updated, datetime): raise ValueError('Invalid datetime format') @@ -670,9 +671,9 @@ class FeedGenerator(object): ''' if not generator is None: self.__atom_generator = {'value':generator} - if not version in None: + if not version is None: self.__atom_generator['version'] = version - if not uri in None: + if not uri is None: self.__atom_generator['uri'] = uri self.__rss_generator = generator return self.__atom_generator @@ -846,7 +847,7 @@ class FeedGenerator(object): :returns: Publication date as datetime.datetime ''' if not pubDate is None: - if isinstance(pubDate, basestring): + if isinstance(pubDate, string_types): pubDate = dateutil.parser.parse(pubDate) if not isinstance(pubDate, datetime): raise ValueError('Invalid datetime format') diff --git a/setup.py b/setup.py index 059dcb7..87d87ef 100755 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ setup( url = 'http://lkiesow.github.io/python-feedgen', keywords = ['feed','ATOM','RSS','podcast'], license = 'FreeBSD and LGPLv3+', - install_requires = ['lxml', 'dateutils'], + install_requires = ['lxml', 'dateutils', 'six'], classifiers = [ 'Development Status :: 4 - Beta', 'Development Status :: 5 - Production/Stable',