add get_true method to ListDict

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@2471 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2005-03-29 11:30:47 +00:00
parent f141255ab2
commit 63a71baae6

View file

@ -133,6 +133,15 @@ class ListDict (dict):
self._keys = []
super(ListDict, self).clear()
def get_true (self, key, default):
"""
Reteurn default element if key is not in the dict, of if the
self[key] evaluates to False.
"""
if key not in self or not self[key]:
return default
return self[key]
class Node (object):
"""