Commits

Anonymous committed e94b1f2

As Postrank is closing, I remove postrank command and subscriptions to postrank feeds. Feeds already subscribed via postrank are resubscribed to normal URL on first opportunity (on first greader2org put)

  • Participants
  • Parent commits 94f9b7b
  • Tags 1.4.0

Comments (0)

Files changed (6)

 
 from setuptools import setup, find_packages
 
-version = '1.3.0'
+version = '1.4.0'
 long_description = open("README.txt").read()
 classifiers = [
     "Programming Language :: Python",
         },
       zip_safe = True,
       install_requires=[
-        'lxml', 'simplejson', 'keyring', 'mekk.greader', 'mekk.postrank'
+        'lxml', 'simplejson', 'keyring', 'mekk.greader',
       ],
       tests_require=[
         'nose',

src/mekk/feeds/greader2org/base_command.py

     atrybutów
     """
 
-    def __init__(self, reader_client, org_file, postrank_client):
+    def __init__(self, reader_client, org_file):
         self.reader = reader_client
-        self.postrank = postrank_client
         self.org = org_file
 
     def execute(self):

src/mekk/feeds/greader2org/run.py

 from initial_load import InitialLoad
 from update_from_google import UpdateFromGoogle
 from update_to_google import UpdateToGoogle
-from update_from_postrank import UpdateFromPostrank
 from settings import Settings
 from mekk.postrank import PostRankClient
-from mekk.greader import GoogleReaderClient, GoogleLoginFailed, GoogleOperationFailed
+from mekk.greader import GoogleReaderClient, GoogleLoginFailed #, GoogleOperationFailed
 from mekk.feeds.orgfile import OrgFile
 import sys,os
 
     init = InitialLoad,
     get = UpdateFromGoogle,
     put = UpdateToGoogle,
-    postrank = UpdateFromPostrank,
 )
 
 def help():
    Checks for the feeds newly subscribed in Google Reader and 
    adds them to the (existing) feeds.org file.
 
-%(name)s postrank - update feeds.org with postrank feed identifiers
-
-   For any feed that is not private and is not disabled (and does not
-   already have postrank_feed set) grabs the postrank feed url. Makes
-   it possible to use postrank filtering.
-
 %(name)s put   - push changes back to Google Reader
 
    Analyzes the feeds.org file (= your edits) and saves those changes
    - unsubscribes feeds marked as :disabled:
    - adds/removes Reader tags according to the file structure
    - subscribes new feeds (in particular, those no longer :disabled:)
-   - replaces default feeds with PostRank feeds (for filtered feeds)
 
 %(name)s configure - reconfigure the script
 
     if command == "configure":
         return
 
-    postrank = PostRankClient("mekk.waw.pl")
     org_file = OrgFile(settings.org_file(), True)
     
-    cmdobj = COMMANDS[sys.argv[1]](reader, org_file, postrank)
+    cmdobj = COMMANDS[sys.argv[1]](reader, org_file)
     cmdobj.execute()
 
 

src/mekk/feeds/greader2org/update_from_postrank.py

-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-from collections import defaultdict
-from base_command import BaseCommand
-from helpers import true_categories
-import logging
-
-log = logging.getLogger("greader2org")
-
-class UpdateFromPostrank(BaseCommand):
-    """
-    Uzupełnia plik feeds.org na bazie wpisów Postrank
-    """
-
-    def execute(self):
-        if not self.org.exists():
-            raise Exception("%s does not exist. Use\n  greader2org init\nto create initial version" % self.org.file_name)
-
-        try:
-            self.grab_postranks()
-        finally:
-            self.org.save_to()
-
-    def grab_postranks(self):
-        not_found = []
-        for folder in self.org.folders:
-            for feed in folder.feeds:
-                if feed.postrank_feed:
-                    continue
-                if ('disabled' in feed.tags) or ('private' in feed.tags):
-                    continue
-                if feed.feed:
-                    print "Checking postrank URL for %s" % feed.title
-                    try:
-                        info = self.postrank.feed_info(feed.feed)
-                    except Exception, e:
-                        print "... failure (%s)" % str(e)
-                        continue
-                    if info:
-                        id = info.get('id')
-                    else:
-                        id = None
-                    if id:
-                        print "... found (adding)"
-                        #http://feeds.postrank.com/bbb2cce1a12c1995b6b74f87c620d282?level=good
-                        feed.postrank_feed = "http://feeds.postrank.com/%s" % id
-                    else:
-                        print "... not found"
-                        not_found.append(feed.feed)
-        
-        self.org.save_to()
-
-        if not_found:
-            print
-            print "The following feeds are missing:"
-            print
-            for f in not_found:
-                print f
-            print
-            print "To ensure PostRank monitors them, login to http://postrank.com"
-            print "visit MyFeeds, click Import, select Direct Input and paste there"
-            print "the list of URLs printed above"

src/mekk/feeds/greader2org/update_to_google.py

         
                 new_url = feed.feed
                 if not ('private' in feed.tags) and feed.postrank_feed and feed.level:
-                    new_url = feed.postrank_feed
-                    if feed.level and feed.level in ['best', 'great', 'good']:
-                        new_url += "?level=%s" % feed.level
+                    if old_url and old_url.startswith(feed.postrank_feed):
+                        print "Postrank is closed, no level-based filtering is possible. Resubscribing %s to default url" % feed.title
+                    else:
+                        print "Postrank is closed, no level-based filtering is possible, ignoring level tags in %s" % feed.title
+                    #new_url = feed.postrank_feed
+                    #if feed.level and feed.level in ['best', 'great', 'good']:
+                    #    new_url += "?level=%s" % feed.level
         
                 if not gf:
                     print "New (or un-disabled) feed, subscribing: %s" % feed.title
                     if changes_count >= CHANGES_LIMIT: sys.exit(0)
         
                 elif new_url != old_url:
-                    print "Feed url changed (postrank?) from %s to %s, resubscribing" % (old_url, new_url)
+                    print "Feed url changed from %s to %s, resubscribing" % (old_url, new_url)
                     rc.subscribe_feed(new_url, feed.title)
                     rc.add_feed_tag(new_url, feed.title, folder.folder_label)
                     rc.unsubscribe_feed(old_url)

src/mekk/feeds/orgfile/org_file.py

         self.title = title.replace("\n", " ").replace("\r", "")
         self.tags = (tags or [])
         self.feed = feed
-        self.postrank_feed = postrank_feed
         self.level = level
         self.comment = comment
+        # Note Postrank feeds are no longer added or saved, but can
+        # be read in historical files, therefore we leave this attribute,
+        # at least for some time
+        self.postrank_feed = postrank_feed
 
     def save(self, f):
         f.write("** %s" % self.title.encode("utf-8"))
         f.write("\n\n")
         for name, value in [
             ('feed', self.feed),
+            # Saving those until resubscribed
             ('postrank_feed', self.postrank_feed),
             ('level', self.level),
             ('comment', self.comment),
         """
         if self.feed and self.feed == url:
             return self
+        # See comment above: those feeds still can be found here or there
         if self.postrank_feed and self.postrank_feed == url:
             return self
         return None