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

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

from initial_load import InitialLoad
from update_from_google import UpdateFromGoogle
from update_to_google import UpdateToGoogle
from settings import Settings
from mekk.greader import GoogleReaderClient, GoogleLoginFailed #, GoogleOperationFailed
from mekk.feeds.orgfile import OrgFile
import sys,os

import logging
#logging.basicConfig(level = logging.DEBUG)
logging.basicConfig(level = logging.WARN)

COMMANDS = dict(
    init = InitialLoad,
    get = UpdateFromGoogle,
    put = UpdateToGoogle,

def help():
    print """Usage:
%(name)s init  - create initial

   Downloads your current Google Reader subscriptions, and saves
   them as (new) file. Use it only once.

%(name)s get   - update

   Checks for the feeds newly subscribed in Google Reader and 
   adds them to the (existing) file.

%(name)s put   - push changes back to Google Reader

   Analyzes the file (= your edits) and saves those changes
   back to Google Reader:
   - unsubscribes feeds marked as :disabled:
   - adds/removes Reader tags according to the file structure
   - subscribes new feeds (in particular, those no longer :disabled:)

%(name)s configure - reconfigure the script

   Change your Google username, customize the feeds file location.

""" % dict(name = os.path.basename(sys.argv[0]))

def main():
    settings = Settings()

    command = ""
    if len(sys.argv) == 2:
        command = sys.argv[1]
    if not command or command == "help":

    if command == "configure":

    while True:
            auth = settings.google_auth()
            reader = GoogleReaderClient(** auth)
        except GoogleLoginFailed:
            print "Login to Google (as %s) failed" % auth['login']

    if command == "configure":

    org_file = OrgFile(settings.org_file(), True)
    cmdobj = COMMANDS[sys.argv[1]](reader, org_file)
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.