Skip to content

Commit

Permalink
PEP-8 and nosetests fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
thp committed Mar 16, 2015
1 parent 6e18a84 commit e17fd94
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
7 changes: 2 additions & 5 deletions makefile
Original file line number Diff line number Diff line change
@@ -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 ""
Expand All @@ -15,7 +12,7 @@ help:
@echo ""

test:
$(NOSETESTS) $(NOSEOPTIONS)
$(NOSETESTS)

clean:
$(FIND) . -name '*.pyc' -o -name __pycache__ -exec $(RM) -r '{}' +
Expand Down
19 changes: 9 additions & 10 deletions podcastparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')

Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -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
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
PACKAGE = 'podcastparser'

MODULES = (
'podcastparser',
'podcastparser',
)

AUTHOR_EMAIL = metadata['author']
Expand All @@ -34,5 +34,4 @@
author_email=EMAIL,
license=LICENSE,
url=WEBSITE,
py_modules=MODULES,
)
py_modules=MODULES)
1 change: 1 addition & 0 deletions test_podcastparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import podcastparser


def test_rss_parsing():
def test_parse_rss(rss_filename):
basename, _ = os.path.splitext(rss_filename)
Expand Down

0 comments on commit e17fd94

Please sign in to comment.