Commits

Marcin Kasperski  committed 5947aba

Explicitly warning about removal of unknown attribute from rewritten org
file.

Dropping almost all refs to postrank.

  • Participants
  • Parent commits 7150ade
  • Tags 1.4.1

Comments (0)

Files changed (4)

File src/mekk/feeds/greader2org/initial_load.py

             print "Creating folder %s" % label
 
             for info in subscribed[label]:
-                feed = Feed(info['title'], [], info['feed'],
-                            None, None, "")
+                feed = Feed(title=info['title'],
+                            tags=[], 
+                            feed=info['feed'],
+                            level=None, 
+                            comment="")
                 folder.add_feed(feed)
                 print "   adding feed %s" % info['title']
         

File src/mekk/feeds/greader2org/update_from_google.py

         
         all_google_feeds = set()
 
-        re_postrank = re.compile(
-            r'^(http://feeds.postrank.com/[^\?]+)\?level=\w+$')
-        
         for item in subs['subscriptions']:
             feed_url = item['id']
             if feed_url.startswith("feed/"):
             else:
                 raise Exception("Ugly feed: %s" % feed_url)
         
-            # In case some postrank feed is still present on Google,
-            # we replace it with normal URL
-            m = re_postrank.match(feed_url)
-            if m:
-                feed_url = m.group(1)
-
             title = item['title']
         
             folder = "ZZZ: Unlabeled"
                 print "New feed %s in category %s" % (title, folder)
                 lab = self.org.find_or_create_folder(folder)
                 lab.add_feed(
-                    Feed(title, [], feed_url, None, None, None) )
+                    Feed(title=title, 
+                         tags=[], 
+                         feed=feed_url, 
+                         level=None, 
+                         comment=None))
         
             all_google_feeds.add(feed_url)
         
                     if 'disabled' not in org_feed.tags:
                         print "Marking unsubscribed feed %s as disabled" % org_feed.title
                         org_feed.tags.append('disabled')
-                # Drop postrank_feed attribute if still present
-                if org_feed.postrank_feed:
-                    if org_feed.feed:
-                        print "Dropping legacy postrank_feed info for %s" % org_feed.title
-                        org_feed.postrank_feed = None
-                    else:
-                        print "Feed %s has only postrank url specified, so is usess. Consider removing it"
         
         self.org.save_to()

File src/mekk/feeds/greader2org/update_to_google.py

 
 class UpdateToGoogle(BaseCommand):
     """
-    Uzupełnia plik feeds.org na bazie zawartości w Google
+    Forward changes from feeds file to GoogleReader
     """
 
     def execute(self):
         # tag (dla nieotagowanych 'ZZZ: Unlabeled') ---> lista elementów
         subscribed = defaultdict(lambda : [])
         
-        # Klucz: url feedu - ale BEZ postrankowych parametrów jeśli były.
+        # Klucz: url feedu
         # Wartości: słowniczek o polach feed_url, title, categories (lista!)
         all_google_feeds = dict()
-        
-        re_postrank = re.compile("^(http://feeds.postrank.com.*)\?level=\w+$")
-        
+
         for item in subs['subscriptions']:
             feed_url = item['id']
             if feed_url.startswith("feed/"):
                 continue   # starred, broadcast itp
             else:
                 raise Exception("Ugly feed: %s" % feed_url)
-        
+
             title = item['title']
             cat = [ x['label'] for x in true_categories(item['categories']) ]
         
-            key_url = feed_url
-            m = re_postrank.match(key_url)
-            if m:
-                key_url = m.group(1)
-        
-            all_google_feeds[ key_url ] = dict(
+            all_google_feeds[ feed_url ] = dict(
                 title = title, categories = cat, feed_url = feed_url )
-        
+
         changes_count = 0
         
         for folder in self.org.folders:
             for org_feed in folder.feeds:
                 gf = all_google_feeds.get( org_feed.feed )
-                if not gf and org_feed.postrank_feed:
-                    gf = all_google_feeds.get( org_feed.postrank_feed )
                 if gf:
                     old_url = gf['feed_url']
         
                     continue
         
                 new_url = org_feed.feed
-                if not ('private' in org_feed.tags) and org_feed.postrank_feed and org_feed.level:
-                    if old_url and old_url.startswith(org_feed.postrank_feed):
-                        print "Postrank is closed, no level-based filtering is possible. Resubscribing %s to default url" % org_feed.title
-                    else:
-                        print "Postrank is closed, no level-based filtering is possible, ignoring level tags in %s" % org_feed.title
         
                 if not gf:
                     print "New (or un-disabled) feed, subscribing: %s" % org_feed.title
                     rc.unsubscribe_feed(old_url)
                     changes_count += 1
                     if changes_count >= CHANGES_LIMIT: sys.exit(0)
-        
                 else:
                     if org_feed.title != gf['title']:
                         print "Changing title from %s to %s" % (gf['title'], org_feed.title)

File src/mekk/feeds/orgfile/org_file.py

         self.feeds.sort( key = lambda x: (x.title, x.feed, hash(x)) )
 
 class Feed(object):
-    def __init__(self, title, tags, feed, postrank_feed, level, comment):
+    def __init__(self, title, tags, feed, level, comment):
         self.title = title.replace("\n", " ").replace("\r", "")
         self.tags = (tags or [])
         self.feed = 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),
             ]:
 
     def find_feed(self, url):
         """
-        Jeśli url jest równy "mojemu" urlowi - zwykłemu lub postrankowemu
-        - to zwracam siebie. Wpp None
+        Jeśli url jest równy "mojemu" urlowi - to zwracam siebie. Wpp None
         """
         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
 
 class OrgFile(object):
                         title = m.string[0:m.start(0)].rstrip()
                         tags = m.group(1).split(':')[0:-1]
                     folder.add_feed(
-                        Feed(title,
-                             tags,
-                             feed.feed.decode("utf-8"), 
-                             feed.postrank_feed.decode("utf-8"),
-                             feed.level,
-                             feed.comment.decode("utf-8")))
+                        Feed(title=title,
+                             tags=tags,
+                             feed=feed.feed.decode("utf-8"), 
+                             level=feed.level,
+                             comment=feed.comment.decode("utf-8")))
+                    for name, value in feed.items():
+                        if not name in ['feed', 'title', 'level', 'comment']:
+                            print "Removing unknown attribute %s (value %s) from feed %s" % (name, value, title)
                 self.folders.append(folder)
             if auto_sort_items:
                 self.sort_items()