# HG changeset patch # User Paul Boddie # Date 1422142180 -3600 # Node ID 2f494c872a4c52460ce447281098be1e0ff65bc7 # Parent 11308c50b0557cec0b708fc5ff40dca9fc756633 Change get_item to return None when many items are found. diff -r 11308c50b055 -r 2f494c872a4c imiptools/content.py --- a/imiptools/content.py Sun Jan 25 00:18:48 2015 +0100 +++ b/imiptools/content.py Sun Jan 25 00:29:40 2015 +0100 @@ -42,15 +42,18 @@ """ Get all items from 'd' with the given 'name', returning single items if 'all' is specified and set to a false value and if only one value is - present for the name. Return None if no items are found for the name. + present for the name. Return None if no items are found for the name or if + many items are found but 'all' is set to a false value. """ if d.has_key(name): values = d[name] - if not all and len(values) == 1: + if all: + return values + elif len(values) == 1: return values[0] else: - return values + return None else: return None