diff --git a/.travis.yml b/.travis.yml index c010786..84f775a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: python python: # - "2.6" -# - "2.7" + - "2.7" - "3.3" - "3.4" - "3.5" diff --git a/doc/index.rst b/doc/index.rst index d4cf6a7..3e70bcd 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -43,6 +43,8 @@ head around ambiguous, undocumented APIs. PodGen incorporates the industry's best practices and lets you focus on collecting the necessary metadata and publishing the podcast. +PodGen is compatible with Python 2.7 and 3.3+. + User Guide ---------- diff --git a/doc/user/installation.rst b/doc/user/installation.rst index b91b64c..87f1288 100644 --- a/doc/user/installation.rst +++ b/doc/user/installation.rst @@ -2,6 +2,9 @@ Installation ============ +PodGen can be used on any system (if not: file a bug report!), and supports +Python 2.7 and 3.3, 3.4 and 3.5. + Use `pip `_:: $ pip install podgen diff --git a/podgen/media.py b/podgen/media.py index 4a18bde..0fe6478 100644 --- a/podgen/media.py +++ b/podgen/media.py @@ -11,6 +11,7 @@ """ import warnings from future.moves.urllib.parse import urlparse +from future.utils import raise_from import datetime from podgen.not_supported_by_itunes_warning import NotSupportedByItunesWarning @@ -246,11 +247,11 @@ def get_type(self, url): try: return self.file_types[file_extension] except KeyError as e: - raise ValueError("The file extension %s was not recognized, which " - "means it's not supported by iTunes. If this is " - "intended, please provide the type yourself so " - "clients can see what type of file it is." - % file_extension) from e + raise_from(ValueError( + "The file extension %s was not recognized, which means it's " + "not supported by iTunes. If this is intended, please provide " + "the type yourself so clients can see what type of file it is." + % file_extension), e) @property def duration(self): diff --git a/podgen/podcast.py b/podgen/podcast.py index 50d7a8b..c49c175 100644 --- a/podgen/podcast.py +++ b/podgen/podcast.py @@ -643,7 +643,7 @@ def _get_xslt_pi(self): return etree.tostring(etree.ProcessingInstruction( "xml-stylesheet", 'type="text/xsl" href="' + quote_sanitized + '"', - ), encoding=str) + ), encoding="UTF-8").decode("UTF-8") def __str__(self): """Print the podcast in RSS format, using the default options. @@ -660,12 +660,12 @@ def rss_str(self, minimize=False, encoding='UTF-8', lines and adding properly indentation, saving bytes at the cost of readability (default: False). :type minimize: bool - :param encoding: Encoding used in the XML file (default: UTF-8). + :param encoding: Encoding used in the XML declaration (default: UTF-8). :type encoding: str :param xml_declaration: Whether an XML declaration should be added to the output (default: True). :type xml_declaration: bool - :returns: The generated RSS feed as a :obj:`str`. + :returns: The generated RSS feed as a :obj:`str` (unicode in 2.7) """ feed = self._create_rss() rss = etree.tostring(feed, pretty_print=not minimize, encoding=encoding, @@ -1133,7 +1133,7 @@ def skip_days(self, days): if not d.lower() in ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']: raise ValueError('Invalid day %s' % d) - self.__skip_days = {day.capitalize() for day in days} + self.__skip_days = set(day.capitalize() for day in days) else: self.__skip_days = None diff --git a/podgen/tests/test_media.py b/podgen/tests/test_media.py index 5d25801..aa1cda0 100644 --- a/podgen/tests/test_media.py +++ b/podgen/tests/test_media.py @@ -112,13 +112,13 @@ def test_autoRecognizeType(self): # Mapping between url file extension and type given by iTunes # https://help.apple.com/itc/podcasts_connect/#/itcb54353390 types = { - '.mp3': {"audio/mpeg"}, - '.m4a': {"audio/x-m4a"}, - '.mov': {"video/quicktime"}, - '.mp4': {"video/mp4"}, - '.m4v': {"video/x-m4v"}, - '.pdf': {"application/pdf"}, - '.epub': {"document/x-epub"}, + '.mp3': set(["audio/mpeg"]), + '.m4a': set(["audio/x-m4a"]), + '.mov': set(["video/quicktime"]), + '.mp4': set(["video/mp4"]), + '.m4v': set(["video/x-m4v"]), + '.pdf': set(["application/pdf"]), + '.epub': set(["document/x-epub"]), } for (file_extension, allowed_types) in iteritems(types): diff --git a/podgen/tests/test_podcast.py b/podgen/tests/test_podcast.py index f5accb8..4a42911 100644 --- a/podgen/tests/test_podcast.py +++ b/podgen/tests/test_podcast.py @@ -13,6 +13,7 @@ from lxml import etree import tempfile import os +from future.utils import raise_from from podgen import Person, Category, Podcast import podgen.version @@ -53,8 +54,8 @@ def setUp(self): 'email': 'Contributor email'} self.copyright = "The copyright notice" self.docs = 'http://www.rssboard.org/rss-specification' - self.skip_days = {'Tuesday'} - self.skip_hours = {23} + self.skip_days = set(['Tuesday']) + self.skip_hours = set([23]) self.explicit = False @@ -454,12 +455,12 @@ def test_mandatoryValues(self): # Try to create a Podcast once for each mandatory property. # On each iteration, exactly one of the properties is not set. # Therefore, an exception should be thrown on each iteration. - mandatory_properties = { + mandatory_properties = set([ "description", "title", "link", "explicit", - } + ]) for test_property in mandatory_properties: fg = Podcast() @@ -474,8 +475,8 @@ def test_mandatoryValues(self): try: self.assertRaises(ValueError, fg._create_rss) except AssertionError as e: - raise AssertionError("The test failed for %s" % test_property)\ - from e + raise_from(AssertionError( + "The test failed for %s" % test_property), e) def test_withholdFromItunesOffByDefault(self): assert not self.fg.withhold_from_itunes diff --git a/readme.md b/readme.md index d3d14ad..9932eec 100644 --- a/readme.md +++ b/readme.md @@ -8,7 +8,7 @@ PodGen (forked from python-feedgen) This module can be used to generate podcast feeds in RSS format, and is -compatible with Python 3.3+. +compatible with Python 2.7 and 3.3+. It is licensed under the terms of both, the FreeBSD license and the LGPLv3+. Choose the one which is more convenient for you. For more details have a look diff --git a/setup.py b/setup.py index d72f915..23221a4 100755 --- a/setup.py +++ b/setup.py @@ -25,7 +25,9 @@ 'Natural Language :: English', 'Operating System :: OS Independent', 'Programming Language :: Python', - 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5',