Commits

Marcin Kasperski committed c1ccb27

Cleaning postrank remainders.

Comments (0)

Files changed (3)

src/mekk/feeds/greader2org/initial_load.py

 
 class InitialLoad(BaseCommand):
     """
-    Pierwszy import z Google Readera (stworzenie inicjalnej wersji
-    pliku do zarządzania feedami)
+    Initial import from Google Reader (creating first version
+    of text mirror file).
     """
 
     def execute(self):
         
         subs = self.reader.get_subscription_list()
         
-        # tag (dla nieotagowanych 'ZZZ: Unlabeled') ---> lista elementów
+        # tag (for untagged 'ZZZ: Unlabeled') ---> list of matching elements
         subscribed = defaultdict(lambda : [])
         
         for item in subs['subscriptions']:
         
             subscribed[label].append( dict(feed = feed, title = title) )
 
-        #org_save = file(self.org.org_file, "w")
-        
         for label in sorted(subscribed.keys()):
             folder = Folder(label)
             self.org.add_folder(folder)
 
             print "Creating folder %s" % label
 
-            #org_save.write("* %s\n\n" % label.encode("utf-8"))
             for info in subscribed[label]:
-                #org_save.write( ("** %s\n\n   feed: %s\n\n" % (info['title'], info['feed'])).encode("utf-8") )
                 feed = Feed(info['title'], [], info['feed'],
                             None, None, "")
                 folder.add_feed(feed)
                 print "   adding feed %s" % info['title']
         
-        #org_save.close()
         self.org.save_to()
                 

src/mekk/feeds/greader2org/update_from_google.py

             else:
                 raise Exception("Ugly feed: %s" % feed_url)
         
-            # Czyszczenie postrankowatych
+            # In case some postrank feed is still present, replacing
+            # it with normal one
             m = re_postrank.match(feed_url)
             if m:
                 feed_url = m.group(1)
         
             all_google_feeds.add(feed_url)
         
-        # Disabledy
-        
+        # Marking unsubscribed feeds as disabled
         for folder in self.org.folders:
-            for feed in folder.feeds:
-                if feed.feed in all_google_feeds:
+            for org_feed in folder.feeds:
+                if org_feed.feed in all_google_feeds:
                     continue
-                if feed.postrank_feed and (feed.postrank_feed in all_google_feeds):
-                    continue
-                if not 'disabled' in feed.tags:
+                if not 'disabled' in org_feed.tags:
                     print "Marking unsubscribed feed %s as disabled" % feed.title
-                    feed.tags.append('disabled')
+                    org_feed.tags.append('disabled')
         
         self.org.save_to()

src/mekk/feeds/greader2org/update_to_google.py

         # Wartości: słowniczek o polach feed_url, title, categories (lista!)
         all_google_feeds = dict()
         
-        re_par = re.compile("^(http://feeds.postrank.com.*)\?level=\w+$")
+        re_postrank = re.compile("^(http://feeds.postrank.com.*)\?level=\w+$")
         
         for item in subs['subscriptions']:
             feed_url = item['id']
             cat = [ x['label'] for x in true_categories(item['categories']) ]
         
             key_url = feed_url
-            m = re_par.match(key_url)
+            m = re_postrank.match(key_url)
             if m:
                 key_url = m.group(1)
         
         changes_count = 0
         
         for folder in self.org.folders:
-            for feed in folder.feeds:
-                gf = all_google_feeds.get( feed.feed )
-                if not gf and feed.postrank_feed:
-                    gf = all_google_feeds.get( feed.postrank_feed )
+            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']
         
-                if 'disabled' in feed.tags:
+                if 'disabled' in org_feed.tags:
                     if gf:
-                        print "Disabled feed, unsubscribing: %s" % feed.title
+                        print "Disabled feed, unsubscribing: %s" % org_feed.title
                         rc.unsubscribe_feed(old_url)
                         changes_count += 1
                         if changes_count >= CHANGES_LIMIT:
                             sys.exit(0)
                     continue
         
-                new_url = feed.feed
-                if not ('private' in feed.tags) and feed.postrank_feed and 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
+                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" % feed.title
-                    #new_url = feed.postrank_feed
-                    #if feed.level and feed.level in ['best', 'great', 'good']:
-                    #    new_url += "?level=%s" % feed.level
+                        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" % feed.title
-                    rc.subscribe_feed(new_url, feed.title)
-                    rc.add_feed_tag(new_url, feed.title, folder.folder_label)
+                    print "New (or un-disabled) feed, subscribing: %s" % org_feed.title
+                    rc.subscribe_feed(new_url, org_feed.title)
+                    rc.add_feed_tag(new_url, org_feed.title, folder.folder_label)
                     changes_count += 1
                     if changes_count >= CHANGES_LIMIT: sys.exit(0)
         
                 elif new_url != old_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.subscribe_feed(new_url, org_feed.title)
+                    rc.add_feed_tag(new_url, org_feed.title, folder.folder_label)
                     rc.unsubscribe_feed(old_url)
                     changes_count += 1
                     if changes_count >= CHANGES_LIMIT: sys.exit(0)
         
                 else:
-                    if feed.title != gf['title']:
-                        print "Changing title from %s to %s" % (gf['title'], feed.title)
-                        rc.change_feed_title(new_url, feed.title)
+                    if org_feed.title != gf['title']:
+                        print "Changing title from %s to %s" % (gf['title'], org_feed.title)
+                        rc.change_feed_title(new_url, org_feed.title)
                     categories = gf['categories']
                     if not (folder.folder_label in categories):
                         print "Adding feed %s to folder %s" % (
-                            feed.title, folder.folder_label)
-                        rc.add_feed_tag(new_url, feed.title, folder.folder_label)
+                            org_feed.title, folder.folder_label)
+                        rc.add_feed_tag(new_url, org_feed.title, folder.folder_label)
                         changes_count += 1
                         if changes_count >=CHANGES_LIMIT: sys.exit(0)
                     for cat in categories:
                         if cat != folder.folder_label:
                             print "Removing feed %s from folder %s" % (
-                                feed.title, cat)
-                            rc.remove_feed_tag(new_url, feed.title, cat)
+                                org_feed.title, cat)
+                            rc.remove_feed_tag(new_url, org_feed.title, cat)
                             changes_count += 1
                             if changes_count >= CHANGES_LIMIT: sys.exit(0)
         
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 ProjectModifiedEvent.java.
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.