# -*- coding: utf-8 -*- # Copyright © 2015-2017 Carl Chenet # 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 ', urifeed) if not matches: sys.exit('This uri to parse is not formatted correctly: {urifeed}'.format(urifeed)) feedname, finaluri = matches.groups() options['rss_uri'] = finaluri else: options['rss_uri'] = config.get('rss', 'uri') else: sys.exit('{confoption} parameter in the [{section}] section of the configuration file is mandatory. Exiting.'.format(section=section, confoption=confoption)) else: options['rss_uri'] = self.clioptions.rss_uri # get the rss feed for rss parameter of [rss] section feed = feedparser.parse(options['rss_uri']) if not feed: sys.exit('Unable to parse the feed at the following url: {rss}'.format(rss=rss)) ######################################### # no_uri_pattern_no_global_pattern option ######################################### currentoption = 'no_uri_pattern_no_global_pattern' # default value options['nopatternurinoglobalpattern'] = False if config.has_option(section, currentoption): options['nopatternurinoglobalpattern'] = config.getboolean(section, currentoption) ########################### # the cache section ########################### options['cachefile'], options['cache_limit'] = parsecache(self.clioptions.cachefile, config) ########################### # the hashtag section ########################### options['hashtaglist'] = parsehashtaglist(self.clioptions.hashtaglist, config) ########################### # the plugins section ########################### plugins = parseplugins(config) ######################################## # return the final configurations values ######################################## if feeds: self.confs.append((options, config, self.tweetformat, feeds, plugins)) else: self.confs.append((options, config, self.tweetformat, [{'feed': feed, 'patterns': [], 'rssobject': '', 'feedname': feedname}], plugins)) @property def confvalues(self): '''Return the values of the different configuration files''' return self.confs