Generalize listify_output decorator into wrap_output
This commit is contained in:
@@ -38,12 +38,12 @@ def memoize_singlearg(func):#a decorator
|
||||
return ret
|
||||
return Memoizer().__getitem__
|
||||
|
||||
|
||||
|
||||
def listify_output(func):#decorator
|
||||
def new_func(*args, **kwargs):
|
||||
return list(func(*args, **kwargs))
|
||||
return new_func
|
||||
def wrap_output(type):#decorator with parameters
|
||||
def decorator(func):#decorator
|
||||
def new_func(*args, **kwargs):
|
||||
return type(func(*args, **kwargs))
|
||||
return new_func
|
||||
return decorator
|
||||
|
||||
def call(func):#decorator
|
||||
return func()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import glob, os
|
||||
import config
|
||||
from common import memoize, listify_output
|
||||
from common import memoize, wrap_output
|
||||
|
||||
@listify_output
|
||||
@wrap_output(list)
|
||||
def list_all(collection = None):
|
||||
if collection:
|
||||
for i in glob.glob(os.path.join(config.svgdir, collection, "*.svg")):
|
||||
@@ -11,7 +11,7 @@ def list_all(collection = None):
|
||||
for i in glob.glob(os.path.join(config.svgdir, "*.svg")):
|
||||
yield os.path.basename(i)[:-4]
|
||||
|
||||
@listify_output
|
||||
@wrap_output(list)
|
||||
def list_collections():
|
||||
for i in glob.glob(os.path.join(config.svgdir, "*")):
|
||||
if not i.endswith(".svg"):
|
||||
|
||||
Reference in New Issue
Block a user