Browse Source

remove unstable persistentlist dependency. fixes #52

master
Carl Chenet 4 years ago
parent
commit
1bbf8c3b29
4 changed files with 57 additions and 6 deletions
  1. +52
    -0
      feed2tweet/feedcache.py
  2. +4
    -4
      feed2tweet/main.py
  3. +0
    -1
      requirements.txt
  4. +1
    -1
      setup.py

+ 52
- 0
feed2tweet/feedcache.py View File

@ -0,0 +1,52 @@
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2015-2017 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
'''Manage a cache with the ids of the feed entries'''
# standard libraires imports
from collections import deque
import os
import os.path
class FeedCache:
'''FeedCache class'''
def __init__(self, options):
'''Constructore of the FeedCache class'''
self.options = options
self.main()
def getdeque(self):
'''return the deque'''
return self.dbfeed
def main(self):
'''Main of the FeedCache class'''
if os.path.exists(self.options['cachefile']):
with open(self.options['cachefile']) as dbdsc:
dbfromfile = dbdsc.readlines()
dblist = [i.strip() for i in dbfromfile]
self.dbfeed = deque(dblist, self.options['cache_limit'] )
else:
self.dbfeed = deque([], self.options['cache_limit'] )
def append(self, rssid):
'''Append a rss id to the cache'''
self.dbfeed.append(rssid)
def close(self):
'''Close the cache'''
with open(self.options['cachefile'], 'w') as dbdsc:
dbdsc.writelines((''.join([i, os.linesep]) for i in self.dbfeed))

+ 4
- 4
feed2tweet/main.py View File

@ -26,11 +26,11 @@ import sys
# 3rd party libraries imports
import feedparser
from persistentlist import PersistentList
import tweepy
# app libraries imports
from feed2tweet.addtags import AddTags
from feed2tweet.feedcache import FeedCache
from feed2tweet.cliparse import CliParse
from feed2tweet.confparse import ConfParse
from feed2tweet.filterentry import FilterEntry
@ -74,8 +74,8 @@ class Main(object):
tweetformat = conf[2]
feeds = conf[3]
plugins = conf[4]
# open the persistent list
cache = PersistentList(options['cachefile'][0:-3], options['cache_limit'])
# create link to the persistent list
cache = FeedCache(options)
if options['hashtaglist']:
severalwordshashtags = codecs.open(options['hashtaglist'],
encoding='utf-8').readlines()
@ -99,7 +99,7 @@ class Main(object):
# cache the ids of last rss feeds
if not clioptions.all:
for i in entries:
if 'id' in i and i['id'] not in cache:
if 'id' in i and i['id'] not in cache.getdeque():
totweet.append(i)
else:
totweet = entries


+ 0
- 1
requirements.txt View File

@ -1,2 +1 @@
persistentlist>=0.4
tweepy>=3.5.0

+ 1
- 1
setup.py View File

@ -42,7 +42,7 @@ setup(
download_url='https://github.com/chaica/feed2tweet',
packages=find_packages(),
scripts=['scripts/feed2tweet'],
install_requires=['feedparser', 'persistentlist>=0.4', 'tweepy'],
install_requires=['feedparser', 'tweepy'],
extras_require={
'influxdb': ["influxdb"]
}


Loading…
Cancel
Save