decorators: add to_iter() decorator to transform any generator into an iterable object
This commit is contained in:
parent
eba089ceaa
commit
1b7148af20
|
@ -2,6 +2,8 @@ from django.contrib.auth.decorators import login_required
|
|||
from django.http import HttpResponseRedirect
|
||||
from functools import wraps
|
||||
|
||||
from . import utils
|
||||
|
||||
TRANSIENT_USER_TYPES = []
|
||||
|
||||
def is_transient_user(user):
|
||||
|
@ -21,3 +23,9 @@ def to_list(func):
|
|||
def f(*args, **kwargs):
|
||||
return list(func(*args, **kwargs))
|
||||
return f
|
||||
|
||||
def to_iter(func):
|
||||
@wraps(func)
|
||||
def f(*args, **kwargs):
|
||||
return utils.IterableFactory(lambda: func(*args, **kwargs))
|
||||
return f
|
||||
|
|
Loading…
Reference in New Issue