Skip to content

Commit

Permalink
Integration fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
StealthTech committed Jul 18, 2017
1 parent 8103694 commit 9d90fe0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
9 changes: 6 additions & 3 deletions core.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ def menu_option_fetch():

counter = 1
for entry in entries:
entry.parse()
if not entry.url:
entries_no_url.append(entry)
continue

entry.parse()
if entry.request_error:
entries_cant_reach.append(entry)
elif entry.url == '':
entries_no_url.append(entry)
elif len(entry.rss):
entries_has_rss.append(entry)
elif entry.rss_in_text:
Expand All @@ -42,6 +43,8 @@ def menu_option_fetch():
for rss in entry.rss:
print(f' ∟ {subcounter}. {rss}')
subcounter += 1
elif not entry.url:
print(f'{counter}. {entry.entry} :: Invalid entry format')
else:
print(f'{counter}. {entry.url} :: {entry.title} :: No RSS channels found')

Expand Down
3 changes: 2 additions & 1 deletion rssutils/rssutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

_rss_word_pattern = '([^a-z]|^)rss([^a-z]|$)'


def search_rss_meta(html):
soup = BeautifulSoup(html, 'html.parser')
meta = soup.find_all('link', {'type': 'application/rss+xml'})
Expand Down Expand Up @@ -113,7 +114,7 @@ def parse(self):
if title is None or title.text is None:
self.title = '[ Page title is missing ]'
else:
self.title = title.text
self.title = str(title.text).strip()

for handler in Entry.rss_finders:
result = handler(html)
Expand Down
7 changes: 4 additions & 3 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def load(filename):
result = None
try:
with open(filepath, 'r') as f:
result = f.readlines()
result = f.read().strip().split('\n')
except IsADirectoryError as e:
cast_exception(e)
except FileNotFoundError as e:
Expand All @@ -59,8 +59,9 @@ def dump(entries, filename, heading=None):
if heading:
f.write(f'::: {heading} :::\n\n')
if len(entries):
for entry in entries:
f.write(f'Entry: {entry.entry}')
for number, entry in enumerate(entries):
f.write(f'= = = = = = = = = = {number} = = = = = = = = = =\n')
f.write(f'Entry: {entry.entry}\n')
f.write(f'Title: {entry.title}\n')
f.write(f'URL: {entry.url}\n')

Expand Down

0 comments on commit 9d90fe0

Please sign in to comment.