<commit_before>#!/usr/bin/env python
"""
newsblur_interface.py
part of PlainReader by <NAME>
created: 2011-11-04
released under the MIT license (see LICENSE.txt for details)
"""

import newsblur
import RepeatTimer

class Interface():
    def __init__(self):
        self.nb = newsblur.API()
        self.items = {}
        self.mark_read_queue = {}
        
        r = RepeatTimer.RepeatTimer(15.0, self.read)
        r.start()
            
    def checkAuth(self):
        status = self.nb.login('', '')['authenticated']
        return status
    
    def login(self, username, password):
        self.nb.login(username, password)
        
    def refresh(self):
        feeds = self.nb.feeds()['feeds']
        unreadfeeds = {}
        unreadcount = 0
        for feed in feeds:
            if feeds[feed]['ps'] != 0 or feeds[feed]['nt'] != 0:
                unreadfeeds[feed] = feeds[feed]['feed_title']
                unreadcount += (feeds[feed]['ps'] + feeds[feed]['nt'])
                if feed not in self.mark_read_queue:
                    self.mark_read_queue[feed] = []

        feed_array = []
        for feed_id in unreadfeeds:
            feed_array.append(feed_id)
        river = self.nb.river_stories(feed_array)
        allstories = river['stories']
        
        unreadstories = []
        for story in allstories:
            if story['read_status'] == 0:
                nogood = False
                for attr in story['intelligence']:
                    if int(story['intelligence'][attr]) < 0:
                        nogood = True
                if not nogood:
                    story['site_title'] = unreadfeeds['%s' % story['story_feed_id']]
                    unreadstories.append(story)
                    
        self.items['stories'] = unreadstories
        self.items['unreadcount'] = unreadcount<commit_msg>fixed a bug in intelligence filtering<commit_after>#!/usr/bin/env python
"""
newsblur_interface.py
part of PlainReader by <NAME>
created: 2011-11-04
released under the MIT license (see LICENSE.txt for details)
"""

import newsblur
import RepeatTimer

class Interface():
    def __init__(self):
        self.nb = newsblur.API()
        self.items = {}
        self.mark_read_queue = {}
        
        r = RepeatTimer.RepeatTimer(15.0, self.read)
        r.start()
            
    def checkAuth(self):
        status = self.nb.login('', '')['authenticated']
        return status
    
    def login(self, username, password):
        self.nb.login(username, password)
        
    def refresh(self):
        feeds = self.nb.feeds()['feeds']
        unreadfeeds = {}
        unreadcount = 0
        for feed in feeds:
            if feeds[feed]['ps'] != 0 or feeds[feed]['nt'] != 0:
                unreadfeeds[feed] = feeds[feed]['feed_title']
                unreadcount += (feeds[feed]['ps'] + feeds[feed]['nt'])
                if feed not in self.mark_read_queue:
                    self.mark_read_queue[feed] = []

        feed_array = []
        for feed_id in unreadfeeds:
            feed_array.append(feed_id)
        river = self.nb.river_stories(feed_array)
        allstories = river['stories']
        
        unreadstories = []
        for story in allstories:
            if story['read_status'] == 0:
                nogood = False
                # story is no good if any intelligence attributes are -1
                # but a +1 overrides all
                for attr in story['intelligence']:
                    if int(story['intelligence'][attr]) == -1:
                        nogood = True
                for attr in story['intelligence']:
                    if int(story['intelligence'][attr]) == 1:
                        nogood = False
                if not nogood:
                    story['site_title'] = unreadfeeds['%s' % story['story_feed_id']]
                    unreadstories.append(story)
                    
        self.items['stories'] = unreadstories
        self.items['unreadcount'] = unreadcount
{'fraction_non_alphanumeric': 0.11719140429785108, 'fraction_numerical': 0.008745627186406797, 'mean_word_length': 1.768326417704011, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '881193', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1120, 'n_words': 260}