cleaning some code (from MR #9)

This commit is contained in:
Carl Chenet 2017-08-01 16:57:08 +02:00
parent 3aef77acac
commit 65242b02cf
3 changed files with 8 additions and 28 deletions

View file

@ -17,15 +17,9 @@
'''Filter an entry of the RSS feeds''' '''Filter an entry of the RSS feeds'''
# standard library imports # standard library imports
from configparser import SafeConfigParser, NoOptionError, NoSectionError
import os
import os.path
import sys import sys
# 3rd party library imports class FilterEntry:
import feedparser
class FilterEntry(object):
'''FilterEntry class''' '''FilterEntry class'''
def __init__(self, elements, entry, options, byrsspatterns, rssobject, feedname): def __init__(self, elements, entry, options, byrsspatterns, rssobject, feedname):
'''Constructor of the FilterEntry class''' '''Constructor of the FilterEntry class'''

View file

@ -21,12 +21,8 @@ import codecs
import importlib import importlib
import logging import logging
import logging.handlers import logging.handlers
import os
import sys import sys
# 3rd party libraries imports
import feedparser
# app libraries imports # app libraries imports
from feed2toot.addtags import AddTags from feed2toot.addtags import AddTags
from feed2toot.cliparse import CliParse from feed2toot.cliparse import CliParse
@ -36,7 +32,7 @@ from feed2toot.removeduplicates import RemoveDuplicates
from feed2toot.tootpost import TootPost from feed2toot.tootpost import TootPost
from feed2toot.feedcache import FeedCache from feed2toot.feedcache import FeedCache
class Main(object): class Main:
'''Main class of Feed2toot''' '''Main class of Feed2toot'''
def __init__(self): def __init__(self):
@ -164,7 +160,7 @@ class Main(object):
nospace = nospace.replace(" ", "") nospace = nospace.replace(" ", "")
rss['hashtags'].append('#{}'.format(nospace)) rss['hashtags'].append('#{}'.format(nospace))
elements=[] elements = []
for i in tweetformat.split(' '): for i in tweetformat.split(' '):
tmpelement = '' tmpelement = ''
# if i is not an empty string # if i is not an empty string

View file

@ -15,16 +15,7 @@
"""Checks an RSS feed and posts new entries to Mastodon.""" """Checks an RSS feed and posts new entries to Mastodon."""
# standard libraires imports
from configparser import SafeConfigParser, NoOptionError, NoSectionError
from argparse import ArgumentParser
import codecs
import logging
import os
import sys
# 3rd party libraries imports # 3rd party libraries imports
import feedparser
from mastodon import Mastodon from mastodon import Mastodon
class TootPost: class TootPost:
@ -40,13 +31,12 @@ class TootPost:
def main(self): def main(self):
'''Main of the TweetPost class''' '''Main of the TweetPost class'''
mastodon = Mastodon( mastodon = Mastodon(
client_id = self.config.get('mastodon', 'client_credentials'), client_id=self.config.get('mastodon', 'client_credentials'),
access_token = self.config.get('mastodon', 'user_credentials'), access_token=self.config.get('mastodon', 'user_credentials'),
api_base_url = self.config.get('mastodon', 'instance_url') api_base_url=self.config.get('mastodon', 'instance_url')
) )
mastodon.status_post(self.toot, toot_visibility = self.config.get('mastodon', 'toot_visibility', fallback='public')
visibility=self.config.get( mastodon.status_post(self.toot, visibility=toot_visibility)
'mastodon', 'toot_visibility', fallback='public'))
def storeit(self): def storeit(self):
'''Indicate if the tweet should be stored or not''' '''Indicate if the tweet should be stored or not'''