in lib/ramble/spack/util/unparse/unparser.py [0:0]
def visit_Call(self, node):
self.set_precedence(_Precedence.ATOM, node.func)
args = node.args
if self._py_ver_consistent:
# make print(a, b, c) and print((a, b, c)) equivalent, since you can't
# tell them apart between Python 2 and 3. See _Print() for more details.
if getattr(node.func, "id", None) == "print":
if len(node.args) == 1 and isinstance(node.args[0], ast.Tuple):
args = node.args[0].elts
self.dispatch(node.func)
with self.delimit("(", ")"):
comma = False
# starred arguments last in Python 3.5+, for consistency w/earlier versions
star_and_kwargs = []
move_stars_last = sys.version_info[:2] >= (3, 5)
for e in args:
if move_stars_last and isinstance(e, ast.Starred):
star_and_kwargs.append(e)
else:
if comma:
self.write(", ")
else:
comma = True
self.dispatch(e)
for e in node.keywords:
# starting from Python 3.5 this denotes a kwargs part of the invocation
if e.arg is None and move_stars_last:
star_and_kwargs.append(e)
else:
if comma:
self.write(", ")
else:
comma = True
self.dispatch(e)
if move_stars_last:
for e in star_and_kwargs:
if comma:
self.write(", ")
else:
comma = True
self.dispatch(e)
if sys.version_info[:2] < (3, 5):
if node.starargs:
if comma:
self.write(", ")
else:
comma = True
self.write("*")
self.dispatch(node.starargs)
if node.kwargs:
if comma:
self.write(", ")
else:
comma = True
self.write("**")
self.dispatch(node.kwargs)