From: Adam Sampson Date: Mon, 5 May 2003 01:55:52 +0000 (+0000) Subject: Remove maybe_get (since get does the same thing). X-Git-Tag: v0.4~7 X-Git-Url: http://git.ozo.com/?a=commitdiff_plain;h=939b49a75e066c2ecb8b47c1c86204c1edad3303;p=rawdog%2F.git Remove maybe_get (since get does the same thing). --- diff --git a/rawdog b/rawdog index 0f3766f..fa1e3bf 100644 --- a/rawdog +++ b/rawdog @@ -26,12 +26,6 @@ def hash_item(feed, title, link, description): s = str(feed) + str(title) + str(link) + str(description) return sha.new(s).hexdigest() -def maybe_get(hash, key): - """If hash has a key called key, return its value, else return - None.""" - if hash.has_key(key): return hash[key] - return None - def format_time(secs, config): """Format a time and date nicely.""" t = time.localtime(secs) @@ -60,8 +54,8 @@ class Feed: print "Error fetching " + self.url return - self.etag = maybe_get(p, "etag") - self.modified = maybe_get(p, "modified") + self.etag = p.get("etag") + self.modified = p.get("modified") # In the event that the feed hasn't changed, then both channel # and feed will be empty. @@ -73,12 +67,12 @@ class Feed: feed = self.url for item in p["items"]: - title = maybe_get(item, "title") - link = maybe_get(item, "link") + title = item.get("title") + link = item.get("link") if item.has_key("content_encoded"): description = item["content_encoded"] else: - description = maybe_get(item, "description") + description = item.get("description") hash = hash_item(feed, title, link, description) if articles.has_key(hash):