option [hashtaglist] section. fixes #5

This commit is contained in:
Carl Chenet 2017-04-27 17:58:43 +02:00
parent c1503e1fd1
commit 02e61d68ad
3 changed files with 19 additions and 7 deletions

View file

@ -191,12 +191,13 @@ class ConfParse(object):
if not self.clioptions.hashtaglist:
confoption = 'several_words_hashtags_list'
if config.has_section(section):
options['hashtaglist'] = config.get(section, confoption)
options['hashtaglist'] = os.path.expanduser(options['hashtaglist'])
if not os.path.exists(options['hashtaglist']) or not os.path.isfile(options['hashtaglist']):
sys.exit('The path to the several_words_hashtags_list parameter is not valid: {hashtaglist}'.format(hashtaglist=options['hashtaglist']))
if config.has_option(section, confoption):
options['hashtaglist'] = config.get(section, confoption)
options['hashtaglist'] = os.path.expanduser(options['hashtaglist'])
if not os.path.exists(options['hashtaglist']) or not os.path.isfile(options['hashtaglist']):
sys.exit('The path to the several_words_hashtags_list parameter is not valid: {hashtaglist}'.format(hashtaglist=options['hashtaglist']))
else:
options['hashtaglist'] = False
options['hashtaglist'] = ''
###########################
#
# the plugins section

View file

@ -75,10 +75,12 @@ class Main(object):
plugins = conf[4]
# create link to the persistent list
cache = FeedCache(options)
if options['hashtaglist']:
if 'hashtaglist' in options and options['hashtaglist']:
severalwordshashtags = codecs.open(options['hashtaglist'],
encoding='utf-8').readlines()
severalwordshashtags = [i.rstrip('\n') for i in severalwordshashtags]
else:
severalwordshashtags = []
# reverse feed entries because most recent one should be sent as the last one in Mastodon
for feed in feeds:
# store the patterns by rss