tango-py/tango/utils.py

26 lines
506 B
Python
Raw Normal View History

2019-03-14 06:10:46 +00:00
from tango.value import TangoIdent, TangoExpr
def is_callable(fn):
return hasattr(fn, '__call__')
def is_ident(ident):
return isinstance(ident, TangoIdent)
def is_expr(expr):
return isinstance(expr, TangoExpr)
def resolve_if_ident(scope, val):
if is_ident(val):
scope.get_def(val)
else:
val
def resolve_idents(scope, vals):
resolved = []
for val in vals:
resolved.append(resolve_if_ident(scope, val))
return resolved