Permalink
Browse files

PEP-8 and nosetests fixes

  • Loading branch information...
thp committed Mar 16, 2015
1 parent 6e18a84 commit e17fd94ab484c468fad2d144af5987751de42653
Showing with 23 additions and 18 deletions.
  1. +2 −5 makefile
  2. +9 −10 podcastparser.py
  3. +9 −0 setup.cfg
  4. +2 −3 setup.py
  5. +1 −0 test_podcastparser.py
View
@@ -1,11 +1,8 @@
PACKAGE := podcastparser
NOSEOPTIONS := --cover-erase --with-coverage --cover-package=$(PACKAGE) --with-doctest
PYTHON ?= python
FIND ?= find
NOSE = $(shell which nosetests)
NOSETESTS ?= $(PYTHON) $(NOSE)
NOSETESTS ?= $(PYTHON) -m nose
help:
@echo ""
@@ -15,7 +12,7 @@ help:
@echo ""
test:
$(NOSETESTS) $(NOSEOPTIONS)
$(NOSETESTS)
clean:
$(FIND) . -name '*.pyc' -o -name __pycache__ -exec $(RM) -r '{}' +
View
@@ -33,8 +33,7 @@
try:
# Python 2
from htmlentitydefs import entitydefs
entitydefs = dict((key, value.decode('latin-1'))
for key, value in entitydefs.iteritems())
entitydefs = dict((key, value.decode('latin-1')) for key, value in entitydefs.iteritems())
chr = unichr
except ImportError:
# Python 3
@@ -171,6 +170,7 @@ def start(self, handler, attrs):
handler.add_enclosure(url, file_size, mime_type)
class AtomLink(Target):
def start(self, handler, attrs):
rel = attrs.get('rel', 'alternate')
@@ -221,6 +221,7 @@ def end(self, handler, text):
elif self._mime_type == 'text':
handler.set_episode_attr('description', squash_whitespace(text))
class PodloveChapters(Target):
SUPPORTED_VERSIONS = ('1.1', '1.2')
@@ -249,6 +250,7 @@ def start(self, handler, attrs):
handler.get_episode_attr('chapters').append(chapter)
class Namespace():
# Mapping of XML namespaces to prefixes as used in MAPPING below
NAMESPACES = {
@@ -354,7 +356,7 @@ def map(self, name):
prefix = self.NAMESPACES.get(namespace_uri)
if prefix is None and namespace:
# Proper use of namespaces, but unknown namespace
#logger.warn('Unknown namespace: %s', namespace_uri)
# logger.warn('Unknown namespace: %s', namespace_uri)
# We prefix the tag name here to make sure that it does not
# match any other tag below if we can't recognize the namespace
name = '!%s:%s' % (namespace, name)
@@ -556,12 +558,9 @@ def parse_pubdate(text):
'rss/channel/item/guid': EpisodeGuid('guid'),
'rss/channel/item/title': EpisodeAttr('title', squash_whitespace),
'rss/channel/item/link': EpisodeAttrRelativeLink('link'),
'rss/channel/item/description': EpisodeAttr('description',
squash_whitespace),
'rss/channel/item/itunes:summary': EpisodeAttr('description',
squash_whitespace),
'rss/channel/item/itunes:subtitle': EpisodeAttr('subtitle',
squash_whitespace),
'rss/channel/item/description': EpisodeAttr('description', squash_whitespace),
'rss/channel/item/itunes:summary': EpisodeAttr('description', squash_whitespace),
'rss/channel/item/itunes:subtitle': EpisodeAttr('subtitle', squash_whitespace),
'rss/channel/item/content:encoded': EpisodeAttr('description_html'),
'rss/channel/item/itunes:duration': EpisodeAttr('total_time', parse_time),
'rss/channel/item/pubDate': EpisodeAttr('published', parse_pubdate),
@@ -760,7 +759,7 @@ def normalize_feed_url(url):
return None
# Assume HTTP for URLs without scheme
if not '://' in url:
if '://' not in url:
url = 'http://' + url
scheme, netloc, path, query, fragment = urlparse.urlsplit(url)
View
@@ -0,0 +1,9 @@
[nosetests]
cover-erase = true
with-coverage = true
cover-package = podcastparser
with-doctest = true
[pep8]
max-line-length = 120
exclude = doc/conf.py
View
@@ -13,7 +13,7 @@
PACKAGE = 'podcastparser'
MODULES = (
'podcastparser',
'podcastparser',
)
AUTHOR_EMAIL = metadata['author']
@@ -34,5 +34,4 @@
author_email=EMAIL,
license=LICENSE,
url=WEBSITE,
py_modules=MODULES,
)
py_modules=MODULES)
View
@@ -26,6 +26,7 @@
import podcastparser
def test_rss_parsing():
def test_parse_rss(rss_filename):
basename, _ = os.path.splitext(rss_filename)

0 comments on commit e17fd94

Please sign in to comment.