"""
Update feeds for Django community page.  Requires Mark Pilgrim's excellent
Universal Feed Parser (http://feedparser.org)
"""

from django.core.management.base import BaseCommand

from aggregator.models import Feed


class Command(BaseCommand):
    help = "Updates all RSS Feeds"

    def handle(self, *args, **options):
        verbose = int(options['verbosity']) > 0
        for feed in Feed.objects.filter(is_functional=True):
            if verbose:
                print
                print "%s - URL: %s" % (feed.title, feed.feed_url)
                print '=' * 80
            feed.parse()
