Skip to content

Commit

Permalink
Fix flake8 complaints
Browse files Browse the repository at this point in the history
This pull request fixes a number of complaints the current version of
flake8 has about the code.
  • Loading branch information
lkiesow committed Dec 21, 2023
1 parent ffe3e4d commit 966fea4
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 50 deletions.
10 changes: 5 additions & 5 deletions feedgen/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@


def print_enc(s):
'''Print function compatible with both python2 and python3 accepting strings
and byte arrays.
'''Print function compatible with both python2 and python3 accepting
strings and byte arrays.
'''
if sys.version_info[0] >= 3:
print(s.decode('utf-8') if isinstance(s, bytes) else s)
Expand Down Expand Up @@ -73,9 +73,9 @@ def main():
fe = fg.add_entry()
fe.id('http://lernfunk.de/_MEDIAID_123#1')
fe.title('First Element')
fe.content('''Lorem ipsum dolor sit amet, consectetur adipiscing elit. Tamen
aberramus a proposito, et, ne longius, prorsus, inquam, Piso, si
ista mala sunt, placet. Aut etiam, ut vestitum, sic sententiam
fe.content('''Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Tamen aberramus a proposito, et, ne longius, prorsus, inquam, Piso,
si ista mala sunt, placet. Aut etiam, ut vestitum, sic sententiam
habeas aliam domesticam, aliam forensem, ut in fronte ostentatio
sit, intus veritas occultetur? Cum id fugiunt, re eadem defendunt,
quae Peripatetici, verba.''')
Expand Down
50 changes: 25 additions & 25 deletions feedgen/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def _add_text_elm(entry, data, name):


class FeedEntry(object):
'''FeedEntry call representing an ATOM feeds entry node or an RSS feeds item
node.
'''FeedEntry call representing an ATOM feeds entry node or an RSS feeds
item node.
'''

def __init__(self):
Expand Down Expand Up @@ -115,8 +115,8 @@ def atom_entry(self, extensions=True):
# element.
if not self.__atom_content:
links = self.__atom_link or []
if not [l for l in links if l.get('rel') == 'alternate']:
raise ValueError('Entry must contain an alternate link or ' +
if not [link for link in links if link.get('rel') == 'alternate']:
raise ValueError('Entry must contain an alternate link or '
'a content element.')

# Add author elements
Expand All @@ -136,18 +136,18 @@ def atom_entry(self, extensions=True):

_add_text_elm(entry, self.__atom_content, 'content')

for l in self.__atom_link or []:
link = xml_elem('link', entry, href=l['href'])
if l.get('rel'):
link.attrib['rel'] = l['rel']
if l.get('type'):
link.attrib['type'] = l['type']
if l.get('hreflang'):
link.attrib['hreflang'] = l['hreflang']
if l.get('title'):
link.attrib['title'] = l['title']
if l.get('length'):
link.attrib['length'] = l['length']
for link in self.__atom_link or []:
link = xml_elem('link', entry, href=link['href'])
if link.get('rel'):
link.attrib['rel'] = link['rel']
if link.get('type'):
link.attrib['type'] = link['type']
if link.get('hreflang'):
link.attrib['hreflang'] = link['hreflang']
if link.get('title'):
link.attrib['title'] = link['title']
if link.get('length'):
link.attrib['length'] = link['length']

_add_text_elm(entry, self.__atom_summary, 'summary')

Expand Down Expand Up @@ -449,13 +449,13 @@ def link(self, link=None, replace=False, **kwargs):
{'rel': ['alternate', 'enclosure', 'related', 'self', 'via']},
{'rel': 'alternate'})
# RSS only needs one URL. We use the first link for RSS:
for l in self.__atom_link:
if l.get('rel') == 'alternate':
self.__rss_link = l['href']
elif l.get('rel') == 'enclosure':
self.__rss_enclosure = {'url': l['href']}
self.__rss_enclosure['type'] = l.get('type')
self.__rss_enclosure['length'] = l.get('length') or '0'
for link in self.__atom_link:
if link.get('rel') == 'alternate':
self.__rss_link = link['href']
elif link.get('rel') == 'enclosure':
self.__rss_enclosure = {'url': link['href']}
self.__rss_enclosure['type'] = link.get('type')
self.__rss_enclosure['length'] = link.get('length') or '0'
# return the set with more information (atom)
return self.__atom_link

Expand Down Expand Up @@ -574,8 +574,8 @@ def contributor(self, contributor=None, replace=False, **kwargs):
return self.__atom_contributor

def published(self, published=None):
'''Set or get the published value which contains the time of the initial
creation or first availability of the entry.
'''Set or get the published value which contains the time of the
initial creation or first availability of the entry.
The value can either be a string which will automatically be parsed or
a datetime.datetime object. In any case it is necessary that the value
Expand Down
3 changes: 2 additions & 1 deletion feedgen/ext/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def extend_ns(self):
return dict()

def extend_rss(self, feed):
'''Extend a RSS feed xml structure containing all previously set fields.
'''Extend a RSS feed xml structure containing all previously set
fields.
:param feed: The feed xml root element.
:returns: The feed root element.
Expand Down
4 changes: 2 additions & 2 deletions feedgen/ext/podcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ def itunes_owner(self, name=None, email=None):
return self.__itunes_owner

def itunes_subtitle(self, itunes_subtitle=None):
'''Get or set the itunes:subtitle value for the podcast. The contents of
this tag are shown in the Description column in iTunes. The subtitle
'''Get or set the itunes:subtitle value for the podcast. The contents
of this tag are shown in the Description column in iTunes. The subtitle
displays best if it is only a few words long.
:param itunes_subtitle: Subtitle of the podcast.
Expand Down
24 changes: 12 additions & 12 deletions feedgen/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,18 @@ def _create_atom(self, extensions=True):
uri = xml_elem('uri', author)
uri.text = a.get('uri')

for l in self.__atom_link or []:
link = xml_elem('link', feed, href=l['href'])
if l.get('rel'):
link.attrib['rel'] = l['rel']
if l.get('type'):
link.attrib['type'] = l['type']
if l.get('hreflang'):
link.attrib['hreflang'] = l['hreflang']
if l.get('title'):
link.attrib['title'] = l['title']
if l.get('length'):
link.attrib['length'] = l['length']
for ln in self.__atom_link or []:
link = xml_elem('link', feed, href=ln['href'])
if ln.get('rel'):
link.attrib['rel'] = ln['rel']
if ln.get('type'):
link.attrib['type'] = ln['type']
if ln.get('hreflang'):
link.attrib['hreflang'] = ln['hreflang']
if ln.get('title'):
link.attrib['title'] = ln['title']
if ln.get('length'):
link.attrib['length'] = ln['length']

for c in self.__atom_category or []:
cat = xml_elem('category', feed, term=c['term'])
Expand Down
6 changes: 3 additions & 3 deletions feedgen/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def xml_elem(name, parent=None, **kwargs):


def ensure_format(val, allowed, required, allowed_values=None, defaults=None):
'''Takes a dictionary or a list of dictionaries and check if all keys are in
the set of allowed keys, if all required keys are present and if the values
of a specific key are ok.
'''Takes a dictionary or a list of dictionaries and check if all keys are
in the set of allowed keys, if all required keys are present and if the
values of a specific key are ok.
:param val: Dictionaries to check.
:param allowed: Set of allowed keys.
Expand Down
4 changes: 2 additions & 2 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def test_usage(self):
assert e.code is None

def test_feed(self):
for ftype in 'rss', 'atom', 'podcast', 'torrent', 'dc.rss', 'dc.atom',\
'syndication.rss', 'syndication.atom':
for ftype in 'rss', 'atom', 'podcast', 'torrent', 'dc.rss', \
'dc.atom', 'syndication.rss', 'syndication.atom':
sys.argv = ['feedgen', ftype]
try:
__main__.main()
Expand Down

0 comments on commit 966fea4

Please sign in to comment.