Tweak functor used to find flatteners/storage routines
Make both of these finding functions use similar routines that the utility module now provides since the logic that both use can be shared. Change-Id: Ib941b99945d42f5c0d791e9b2a0696d0e62a2388
This commit is contained in:
@@ -87,6 +87,18 @@ def find_monotonic(allow_time_time=False):
|
||||
return None
|
||||
|
||||
|
||||
def match_type_handler(item, type_handlers):
|
||||
"""Matches a given items type using the given match types + handlers.
|
||||
|
||||
Returns the handler if a type match occurs, otherwise none.
|
||||
"""
|
||||
for (match_types, handler_func) in type_handlers:
|
||||
if isinstance(item, match_types):
|
||||
return handler_func
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def countdown_iter(start_at, decr=1):
|
||||
"""Generator that decrements after each generation until <= zero.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user