mekk.feeds / src / mekk / feeds / greader2org /

# -*- coding: utf-8 -*-

from mekk.feeds.orgfile import Folder, Feed
from collections import defaultdict
from base_command import BaseCommand
from helpers import true_categories
import logging, re

log = logging.getLogger("greader2org")


class UpdateFromGoogle(BaseCommand):
    Uzupełnia plik na bazie zawartości w Google

    def execute(self):
        if not
            raise Exception("%s does not exist. Use\n  greader2org init\nto create initial version" %

        subs = self.reader.get_subscription_list()

        # tag (dla nieotagowanych 'ZZZ: Unlabeled') ---> lista elementów
        subscribed = defaultdict(lambda : [])
        all_google_feeds = set()

        for item in subs['subscriptions']:
            feed_url = item['id']
            if feed_url.startswith("feed/"):
                feed_url = feed_url[5:]
            elif feed_url.startswith("user/"):
                continue   # starred, broadcast itp
                raise Exception("Ugly feed: %s" % feed_url)
            title = item['title']
            folder = "ZZZ: Unlabeled"
            cat = true_categories( item['categories'] )
            if len(cat) > 0:
                folder = cat[0]['label']
                if len(cat) > 1:
                    if WARN_MULTIPLE_CATEGORIES:
                        log.warn("Multiple categories for %s. Using first one of: %s" % (
                            item['id'], ", ".join((x['label'] for x in cat))))
            if not
                print "New feed %s in category %s" % (title, folder)
                lab =
        # Marking unsubscribed feeds as disabled, and other cleanups
        for folder in
            for org_feed in folder.feeds:
                if org_feed.feed not in all_google_feeds:
                    if 'disabled' not in org_feed.tags:
                        print "Marking unsubscribed feed %s as disabled" % org_feed.title
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.