aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bonhomme <kimble.mandel@gmail.com>2013-07-24 08:45:39 +0200
committerCédric Bonhomme <kimble.mandel@gmail.com>2013-07-24 08:45:39 +0200
commita3672bb2705189281cbb062b2455412a56898c72 (patch)
tree840f2ac31fac652c5b7bc8fde3f53489d3e35d22
parentImproved add_feed (diff)
downloadnewspipe-a3672bb2705189281cbb062b2455412a56898c72.tar.gz
newspipe-a3672bb2705189281cbb062b2455412a56898c72.tar.bz2
newspipe-a3672bb2705189281cbb062b2455412a56898c72.zip
Improved remove_feed function.
-rwxr-xr-xsource/utils.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/source/utils.py b/source/utils.py
index 90184020..3f945a87 100755
--- a/source/utils.py
+++ b/source/utils.py
@@ -236,14 +236,16 @@ def remove_feed(feed_url):
"""
Remove a feed from the file feed.lst and from the SQLite base.
"""
- feeds = []
- # Remove the URL from the file feed.lst
- if os.path.exists(conf.FEED_LIST):
- for line in open(conf.FEED_LIST, "r"):
- if feed_url not in line:
- feeds.append(line.replace("\n", ""))
- with open(conf.FEED_LIST, "w") as f:
- f.write("\n".join(feeds))
+ with open(conf.FEED_LIST, "r") as f:
+ lines = f.readlines()
+ lines = list(map(str.strip, lines))
+ try:
+ del lines[lines.index(feed_url)]
+ except:
+ return False
+ with open(conf.FEED_LIST, "w") as f:
+ f.write("\n".join(lines))
+ return True
def search_feed(url):
"""
bgstack15