MCPcopy Create free account
hub / github.com/SpaceNetLab/StarryNet / makeListCompatible

Function makeListCompatible

starrynet/log.py:157–171  ·  view source on GitHub ↗

Return a new function allowing fn( 'a 1 b' ) to be called as newfn( 'a', 1, 'b' )

(fn)

Source from the content-addressed store, hash-verified

155
156
157def makeListCompatible(fn):
158 """Return a new function allowing fn( 'a 1 b' ) to be called as
159 newfn( 'a', 1, 'b' )"""
160
161 def newfn(*args):
162 "Generated function. Closure-ish."
163 if len(args) == 1:
164 return fn(*args)
165 args = ' '.join(str(arg) for arg in args)
166 return fn(args)
167
168 # Fix newfn's name and docstring
169 setattr(newfn, '__name__', fn.__name__)
170 setattr(newfn, '__doc__', fn.__doc__)
171 return newfn
172
173
174_loggers = lg.info, lg.output, lg.warn, lg.error, lg.debug

Callers 1

log.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected