mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-08 00:20:59 +00:00
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:
parent
f141255ab2
commit
63a71baae6
1 changed files with 9 additions and 0 deletions
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue