Author: dmeyer
Date: Sat Sep 15 17:59:29 2007
New Revision: 2815
Log:
rename channel to feed (broken right now, need more commits)
Added:
trunk/beacon/src/server/channel/feed.py
- copied, changed from r2814, /trunk/beacon/src/server/channel/channel.py
Removed:
trunk/beacon/src/server/channel/channel.py
Modified:
trunk/beacon/src/__init__.py
trunk/beacon/src/server/channel/__init__.py
trunk/beacon/src/server/channel/manager.py
trunk/beacon/src/server/channel/rss.py
Modified: trunk/beacon/src/__init__.py
==============================================================================
--- trunk/beacon/src/__init__.py (original)
+++ trunk/beacon/src/__init__.py Sat Sep 15 17:59:29 2007
@@ -198,10 +198,10 @@
class Feed(dict):
def update(self):
- return _client.feed_func('channels.update', self.get('id'))
+ return _client.feed_func('feeds.update', self.get('id'))
def remove(self):
- return _client.feed_func('channels.remove', self.get('id'))
+ return _client.feed_func('feeds.remove', self.get('id'))
@kaa.notifier.yield_execution()
def list_feeds():
@@ -211,7 +211,7 @@
if not _client:
connect()
- async = _client.feed_func('channels.list')
+ async = _client.feed_func('feeds.list')
yield async
feeds = []
for f in async.get_result():
@@ -226,7 +226,12 @@
"""
if not _client:
connect()
- async = _client.feed_func('channels.add', url, destdir, download, num,
keep)
+ async = _client.feed_func('feeds.add', url, destdir, download, num, keep)
yield async
yield Feed(async.get_result())
+def update_feeds():
+ """
+ Update all feeds.
+ """
+ return _client.feed_func('feeds.update')
Modified: trunk/beacon/src/server/channel/__init__.py
==============================================================================
--- trunk/beacon/src/server/channel/__init__.py (original)
+++ trunk/beacon/src/server/channel/__init__.py Sat Sep 15 17:59:29 2007
@@ -1,17 +1,17 @@
# ##################################################################
# Brain Dump
#
-# - Improve RSS channel for better video and audio feed support
-# https://channelguide.participatoryculture.org/front
-# - Flickr image channel
-# - Torrent downloader (needed for some democracy channels)
+# - Improve RSS feed for better video and audio feed support
+# https://feedguide.participatoryculture.org/front
+# - Flickr image feed
+# - Torrent downloader (needed for some democracy feeds)
# - Add more item metadata (e.g. download thumbnail/image)
-# - Channel configuration:
+# - Feed configuration:
# o always download / download on demand / play from stream
# o how much entries should be show
# o keep entries on hd (while in feed / while not watched / up to x)
# - Add parallel download function
-# - Add channel as 'file' to kaa.beacon making it possible to merge
+# - Add feed as 'file' to kaa.beacon making it possible to merge
# feed entries and real files.
# o does it belong into beacon?
# o is it an extra kaa module with beacon plugin?
@@ -22,37 +22,37 @@
import kaa.rpc
import manager
-import channel
+import feed
import rss
[EMAIL PROTECTED]('channels.update')
[EMAIL PROTECTED]('feeds.update')
def update(id=None):
if id == None:
return manager.update()
- for c in manager.list_channels():
+ for c in manager.list_feeds():
if id == c.id:
return c.update()
return False
[EMAIL PROTECTED]('channels.list')
-def list_channels():
- channels = []
- for c in manager.list_channels():
- channels.append(c.get_config())
- return channels
-
[EMAIL PROTECTED]('channels.add')
-def add_channel(url, destdir, download=True, num=0, keep=True):
- return manager.add_channel(url, destdir, download, num, keep).get_config()
-
[EMAIL PROTECTED]('channels.remove')
-def remove_channel(id):
- for c in manager.list_channels():
[EMAIL PROTECTED]('feeds.list')
+def list_feeds():
+ feeds = []
+ for c in manager.list_feeds():
+ feeds.append(c.get_config())
+ return feeds
+
[EMAIL PROTECTED]('feeds.add')
+def add_feed(url, destdir, download=True, num=0, keep=True):
+ return manager.add_feed(url, destdir, download, num, keep).get_config()
+
[EMAIL PROTECTED]('feeds.remove')
+def remove_feed(id):
+ for c in manager.list_feeds():
if id == c.id:
- manager.remove_channel(c)
+ manager.remove_feed(c)
return True
return False
def set_database(database):
- channel.Channel._db = database
+ feed.Feed._db = database
manager.init()
Copied: trunk/beacon/src/server/channel/feed.py (from r2814,
/trunk/beacon/src/server/channel/channel.py)
==============================================================================
--- /trunk/beacon/src/server/channel/channel.py (original)
+++ trunk/beacon/src/server/channel/feed.py Sat Sep 15 17:59:29 2007
@@ -16,10 +16,10 @@
import manager
# get logging object
-log = logging.getLogger('beacon.channel')
+log = logging.getLogger('beacon.feed')
# ##################################################################
-# some generic entry/channel stuff
+# some generic entry/feed stuff
# ##################################################################
IMAGEDIR = os.path.expanduser("~/.beacon/images")
@@ -45,7 +45,7 @@
return kaa.notifier.url.fetch(self.url, filename, tmpname)
-class Channel(object):
+class Feed(object):
_db = None
NEXT_ID = 0
@@ -60,15 +60,15 @@
self._keep = True
if not os.path.isdir(destdir):
os.makedirs(destdir)
- self.id = Channel.NEXT_ID
- Channel.NEXT_ID += 1
+ self.id = Feed.NEXT_ID
+ Feed.NEXT_ID += 1
def configure(self, download=True, num=0, keep=True):
"""
- Configure channel
- num: number of items from the channel (0 == all, default)
- keep: keep old entries not in channel anymore (download only)
+ Configure feed
+ num: number of items from the feed (0 == all, default)
+ keep: keep old entries not in feed anymore (download only)
verbose: print status on stdout
"""
self._download = download
@@ -79,7 +79,7 @@
def get_config(self):
"""
- Get channel configuration.
+ Get feed configuration.
"""
return dict(id = self.id,
url = self.url,
@@ -90,7 +90,7 @@
def _readxml(self, node):
"""
- Read XML node with channel configuration and cache.
+ Read XML node with feed configuration and cache.
"""
for d in node.childNodes:
if not d.nodeName == 'directory':
@@ -107,7 +107,7 @@
def _writexml(self, node):
"""
- Write XML node with channel configuration and cache.
+ Write XML node with feed configuration and cache.
"""
node.setAttribute('url', self.url)
doc = node.ownerDocument
@@ -146,13 +146,13 @@
@kaa.notifier.yield_execution()
def update(self, verbose=False):
"""
- Update channel.
+ Update feed.
"""
def print_status(s):
sys.stdout.write("%s\r" % s.get_progressbar())
sys.stdout.flush()
- log.info('update channel %s', self.url)
+ log.info('update feed %s', self.url)
# get directory information
beacondir = self._db.query(filename=self.dirname)
@@ -241,7 +241,7 @@
@kaa.notifier.yield_execution()
def remove(self):
"""
- Remove entries from this channel.
+ Remove entries from this feed.
"""
log.info('remove %s', self.url)
if self._keep or self._download:
Modified: trunk/beacon/src/server/channel/manager.py
==============================================================================
--- trunk/beacon/src/server/channel/manager.py (original)
+++ trunk/beacon/src/server/channel/manager.py Sat Sep 15 17:59:29 2007
@@ -9,70 +9,70 @@
import rss
# get logging object
-log = logging.getLogger('beacon.channel')
+log = logging.getLogger('beacon.feed')
-CACHE = os.path.expanduser("~/.beacon/channels.xml")
+CACHE = os.path.expanduser("~/.beacon/feeds.xml")
-# list of all channel objects
-_channels = []
+# list of all feed objects
+_feeds = []
-# list of all Channel classes
+# list of all Feed classes
_generators = []
def register(regexp, generator):
"""
- Register a Channel class.
+ Register a Feed class.
"""
_generators.append((regexp, generator))
-def _get_channel(url, destdir):
+def _get_feed(url, destdir):
"""
- Get channel class from generators and create the channel object.
+ Get feed class from generators and create the feed object.
"""
for regexp, generator in _generators:
if regexp.match(url):
return generator(url, destdir)
- return rss.Channel(url, destdir)
+ return rss.Feed(url, destdir)
-def add_channel(url, destdir, download=True, num=0, keep=True):
+def add_feed(url, destdir, download=True, num=0, keep=True):
"""
- Add a new channel.
+ Add a new feed.
"""
- for c in _channels:
+ for c in _feeds:
if c.dirname == destdir and c.url == url:
- raise RuntimeError('channel already exists')
- channel = _get_channel(url, destdir)
- _channels.append(channel)
- channel.configure(download, num, keep)
- return channel
+ raise RuntimeError('feed already exists')
+ feed = _get_feed(url, destdir)
+ _feeds.append(feed)
+ feed.configure(download, num, keep)
+ return feed
-def list_channels():
+def list_feeds():
"""
- Return a list of all channels.
+ Return a list of all feeds.
"""
- return _channels
+ return _feeds
-def remove_channel(channel):
+def remove_feed(feed):
"""
- Remove a channel.
+ Remove a feed.
"""
- _channels.remove(channel)
- channel.remove()
+ _feeds.remove(feed)
+ feed.remove()
save()
def save():
"""
- Save all channel information
+ Save all feed information
"""
- doc = minidom.getDOMImplementation().createDocument(None, "channels", None)
+ doc = minidom.getDOMImplementation().createDocument(None, "feeds", None)
top = doc.documentElement
- for c in _channels:
- node = doc.createElement('channel')
+ for c in _feeds:
+ node = doc.createElement('feed')
c._writexml(node)
top.appendChild(node)
f = open(CACHE, 'w')
@@ -82,18 +82,18 @@
def init():
"""
- Load cached channels from disc.
+ Load cached feeds from disc.
"""
- def parse_channel(c):
+ def parse_feed(c):
for d in c.childNodes:
if not d.nodeName == 'directory':
continue
dirname = unicode_to_str(d.childNodes[0].data.strip())
url = unicode_to_str(c.getAttribute('url'))
- channel = _get_channel(url, dirname)
- channel._readxml(c)
- _channels.append(channel)
+ feed = _get_feed(url, dirname)
+ feed._readxml(c)
+ _feeds.append(feed)
return
if not os.path.isfile(CACHE):
@@ -105,13 +105,13 @@
log.exception('bad cache file: %s' % CACHE)
return
if not len(cache.childNodes) == 1 or \
- not cache.childNodes[0].nodeName == 'channels':
+ not cache.childNodes[0].nodeName == 'feeds':
log.error('bad cache file: %s' % CACHE)
return
for c in cache.childNodes[0].childNodes:
try:
- parse_channel(c)
+ parse_feed(c)
except:
log.exception('bad cache file: %s' % CACHE)
@@ -121,18 +121,15 @@
@kaa.notifier.yield_execution()
def update(verbose=False):
"""
- Update all channels
+ Update all feeds
"""
global _updating
if _updating:
log.error('update already in progress')
yield False
- log.info('start channel update')
+ log.info('start feed update')
_updating = True
- for channel in _channels:
- x = channel.update(verbose=verbose)
- yield x
- log.info('XXXXXXXXX')
- x()
+ for feed in _feeds:
+ yield feed.update(verbose=verbose)
_updating = False
yield True
Modified: trunk/beacon/src/server/channel/rss.py
==============================================================================
--- trunk/beacon/src/server/channel/rss.py (original)
+++ trunk/beacon/src/server/channel/rss.py Sat Sep 15 17:59:29 2007
@@ -6,7 +6,7 @@
import kaa.notifier
import feedparser as _feedparser
-import channel
+import feed
# get logging object
log = logging.getLogger('beacon.feed')
@@ -16,7 +16,7 @@
def feedparser(url):
return _feedparser.parse(urllib2.urlopen(url))
-class Channel(channel.Channel):
+class Feed(feed.Feed):
def __iter__(self):
# get feed in a thread
@@ -89,5 +89,5 @@
# getting a good basename for urls ending with /
# based on type.
# create entry
- entry = channel.Entry(**metadata)
+ entry = feed.Entry(**metadata)
yield entry
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog