Add Python 3 compatibility.

This commit is contained in:
Vincent Driessen 2014-09-20 23:51:04 +02:00 committed by Lars Kiesow
parent 72b2896cf8
commit 626d9df6c4
3 changed files with 9 additions and 7 deletions

View file

@ -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')

View file

@ -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')

View file

@ -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',