refactoring clean-up

git-svn-id: svn://svn.berlios.de/gpodder/trunk@371 b0d088ad-0a06-0410-aad2-9ed5178a7e87
This commit is contained in:
Thomas Perl 2007-08-19 13:01:15 +00:00
parent 5647a0cd5d
commit 7123bd7548
4 changed files with 22 additions and 42 deletions

View File

@ -1,3 +1,11 @@
Sun, 19 Aug 2007 14:57:50 +0200 <thp@perli.net>
! Some re-factoring to simplify our codebase: podcastChannel and OPML
* src/gpodder/libpodcasts.py: Remove unnecessary constructor params
in podcastItem (not used right now); replace getSize() with a call
to util.format_filesize(); remove opmlChannel class
* src/gpodder/libopmlreader.py: use a dict instead of opmlChannel
* src/gpodder/gui.py: remove import statement for podcastItem
Sun, 19 Aug 2007 09:21:44 +0200 <thp@perli.net>
* src/gpodder/libpodcasts.py: Submit modified patch from Richard
Voigt (richardvoigt gmail com) to fix an error with invalid data

View File

@ -45,7 +45,6 @@ from gpodder import util
from SimpleGladeApp import SimpleGladeApp
from libpodcasts import podcastChannel
from libpodcasts import podcastItem
from libpodcasts import channelsToModel

View File

@ -40,8 +40,6 @@ from string import strip
from urllib import unquote_plus
from libpodcasts import opmlChannel
class opmlReader( DefaultHandler, ErrorHandler):
def __init__( self):
@ -65,8 +63,8 @@ class opmlReader( DefaultHandler, ErrorHandler):
for channel in self.channels:
new_iter = new_model.append()
new_model.set( new_iter, 0, False)
new_model.set( new_iter, 1, '<b>%s</b>\n<span size="small">%s</span>' % ( saxutils.escape( channel.title), saxutils.escape( channel.description), ))
new_model.set( new_iter, 2, channel.xmlurl)
new_model.set( new_iter, 1, '<b>%s</b>\n<span size="small">%s</span>' % ( saxutils.escape( channel['title']), saxutils.escape( channel['description']), ))
new_model.set( new_iter, 2, channel['url'])
return new_model
@ -103,7 +101,7 @@ class opmlReader( DefaultHandler, ErrorHandler):
# otype = 'link' to support odeo.com feeds
if name == 'outline' and (otype == 'rss' or otype == 'link') and xmlurl != '':
self.channels.append( opmlChannel( xmlurl, title, description))
self.channels.append( { 'title': title, 'description': description, 'url': xmlurl })
def endElement( self, name):
if name == 'title':

View File

@ -334,7 +334,7 @@ class podcastChannel(ListType):
new_iter = new_model.append()
new_model.set( new_iter, 0, item.url)
new_model.set( new_iter, 1, item.title)
new_model.set( new_iter, 2, item.getSize())
new_model.set( new_iter, 2, util.format_filesize( item.length))
new_model.set( new_iter, 3, True)
new_model.set( new_iter, 4, status_icon)
new_model.set( new_iter, 5, item.cute_pubdate())
@ -516,25 +516,15 @@ class podcastChannel(ListType):
class podcastItem(object):
"""holds data for one object in a channel"""
def __init__( self,
url = "",
title = "",
length = "0",
mimetype = "",
guid = "",
description = "",
link = "",
pubDate = None):
self.url = url
self.title = title
self.length = length
self.mimetype = mimetype
self.guid = guid
self.description = util.remove_html_tags( description)
self.link = ""
self.pubDate = pubDate
if pubDate == None:
self.pubDate = datetime.now().ctime()
def __init__( self):
self.url = ''
self.title = ''
self.length = 0
self.mimetype = ''
self.guid = ''
self.description = ''
self.link = ''
self.pubDate = datetime.now().ctime()
def one_line_description( self):
lines = self.description.strip().splitlines()
@ -577,7 +567,7 @@ class podcastItem(object):
return self.pubDate
else:
return pubdate
def cute_pubdate( self):
seconds_in_a_day = 86400
try:
@ -615,24 +605,9 @@ class podcastItem(object):
title = property(fget=get_title,
fset=set_title)
def getSize( self):
try:
size = int( self.length)
except ValueError:
return '-'
return util.format_filesize( size)
class opmlChannel(object):
def __init__( self, xmlurl, title = 'Unknown OPML Channel', description = ''):
self.title = title
self.xmlurl = xmlurl
self.description = description
class DownloadHistory( ListType):
def __init__( self, filename):
self.filename = filename