예제 #1
0
    def add_category(self):
        dialog = [
            ('string', 'caption', tr('New Category'), tr('Category Name:'),
             None),
        ]
        from modules.EasyGuider import EasyDialog
        easy = EasyDialog.EasyDialog(self.sharewin, tr('Input'), dialog)
        values = None
        if easy.ShowModal() == wx.ID_OK:
            values = easy.GetValue()
        easy.Destroy()
        if values:
            #add category to db
            import RssDb
            RssDb.init(Globals.rss_dbfile)
            category = RssDb.Category(title=values["caption"])
            category.save()

            data = {
                'type': 'rss',
                'level': 'category',
                'caption': values['caption'],
                'data': {
                    'save': False,
                    'id': category.id
                }
            }
            root, node = self.sharewin.get_cur_node()
            obj = self.sharewin.addnode(root, data=data)
            self.add_category_ids(category.id, obj)
예제 #2
0
    def import_opml(self, filename):
        RssDb.init(Globals.rss_dbfile)

        import OPML
        opml = OPML.parse(filename)
        for o in opml.outlines:
            c = RssDb.Category.get_by(title=o['title'])
            if not c:
                c = RssDb.Category(o['title'])
                c.commit()
            for i in o.children:
                f = RssDb.Feed.get_by(category_id=c.id, link=i['xmlUrl'])
                if f:
                    f.title = i['title']
                    f.homelink = i.get('htmlUrl', '')
                    f.description = i.get('description', '')
                    f.commit()
                else:
                    c.feeds.append(
                        RssDb.Feed(title=i['title'],
                                   link=i['xmlUrl'],
                                   homelink=i.get('htmlUrl', ''),
                                   imagelink='',
                                   description=i.get('description', '')))
        RssDb.objectstore.commit()
        item, node = self.sharewin.get_cur_node()
        self.sharewin.reset_cur_item()