Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def p_with_bang_stmt_many_suite(self, p):
"""with_stmt : with_tok BANG with_item comma_with_item_list rawsuite"""
p1, p3, p4, p5 = p[1], p[3], p[4], p[5]
items = [p3] + p4
for item in items:
expr = item.context_expr
l, c = expr.lineno, expr.col_offset
gblcall = xonsh_call("globals", [], lineno=l, col=c)
loccall = xonsh_call("locals", [], lineno=l, col=c)
margs = [expr, p5, gblcall, loccall]
item.context_expr = xonsh_call(
"__xonsh__.enter_macro", margs, lineno=l, col=c
)
body = [ast.Pass(lineno=p5.lineno, col_offset=p5.col_offset)]
p[0] = [
ast.With(items=items, body=body, lineno=p1.lineno, col_offset=p1.lexpos)
]
def p_with_bang_stmt_many_suite(self, p):
"""with_stmt : with_tok BANG with_item comma_with_item_list rawsuite"""
p1, p3, p4, p5 = p[1], p[3], p[4], p[5]
items = [p3] + p4
for item in items:
expr = item.context_expr
l, c = expr.lineno, expr.col_offset
gblcall = xonsh_call("globals", [], lineno=l, col=c)
loccall = xonsh_call("locals", [], lineno=l, col=c)
margs = [expr, p5, gblcall, loccall]
item.context_expr = xonsh_call(
"__xonsh__.enter_macro", margs, lineno=l, col=c
)
body = [ast.Pass(lineno=p5.lineno, col_offset=p5.col_offset)]
p[0] = [
ast.With(items=items, body=body, lineno=p1.lineno, col_offset=p1.lexpos)
]
p1, p2 = p[1], p[2]
if isinstance(p1, LexToken):
p1, p1_tok = p1.value, p1
lineno, col = p1_tok.lineno, p1_tok.lexpos
else:
lineno, col = self.lineno, self.col
if lenp == 3: # $NAME
p0 = self._envvar_by_name(p2, lineno=lineno, col=col)
elif p1 == "${":
xenv = load_attribute_chain("__xonsh__.env", lineno=lineno, col=col)
idx = ast.Index(value=p2)
p0 = ast.Subscript(
value=xenv, slice=idx, ctx=ast.Load(), lineno=lineno, col_offset=col
)
elif p1 == "$(":
p0 = xonsh_call(
"__xonsh__.subproc_captured_stdout", p2, lineno=lineno, col=col
)
elif p1 == "!(":
p0 = xonsh_call(
"__xonsh__.subproc_captured_object", p2, lineno=lineno, col=col
)
elif p1 == "![":
p0 = xonsh_call(
"__xonsh__.subproc_captured_hiddenobject", p2, lineno=lineno, col=col
)
elif p1 == "$[":
p0 = xonsh_call("__xonsh__.subproc_uncaptured", p2, lineno=lineno, col=col)
else:
assert False
return p0
def p_subproc_atom_captured_stdout(self, p):
"""subproc_atom : dollar_lparen_tok subproc RPAREN"""
p1 = p[1]
p0 = xonsh_call(
"__xonsh__.subproc_captured_stdout",
args=p[2],
lineno=p1.lineno,
col=p1.lexpos,
)
p0._cliarg_action = "append"
p[0] = p0
The pymode argument indicate if it is called from subproc or python mode"""
pymode = ast.NameConstant(value=pymode, lineno=lineno, col_offset=col)
searchfunc, pattern = RE_SEARCHPATH.match(pattern).groups()
pattern = ast.Str(s=pattern, lineno=lineno, col_offset=col)
pathobj = False
if searchfunc.startswith("@"):
func = searchfunc[1:]
elif "g" in searchfunc:
func = "__xonsh__.globsearch"
pathobj = "p" in searchfunc
else:
func = "__xonsh__.regexsearch"
pathobj = "p" in searchfunc
func = load_attribute_chain(func, lineno=lineno, col=col)
pathobj = ast.NameConstant(value=pathobj, lineno=lineno, col_offset=col)
return xonsh_call(
"__xonsh__.pathsearch",
args=[func, pattern, pymode, pathobj],
lineno=lineno,
col=col,
)
value=xenv, slice=idx, ctx=ast.Load(), lineno=lineno, col_offset=col
)
elif p1 == "$(":
p0 = xonsh_call(
"__xonsh__.subproc_captured_stdout", p2, lineno=lineno, col=col
)
elif p1 == "!(":
p0 = xonsh_call(
"__xonsh__.subproc_captured_object", p2, lineno=lineno, col=col
)
elif p1 == "![":
p0 = xonsh_call(
"__xonsh__.subproc_captured_hiddenobject", p2, lineno=lineno, col=col
)
elif p1 == "$[":
p0 = xonsh_call("__xonsh__.subproc_uncaptured", p2, lineno=lineno, col=col)
else:
assert False
return p0
def p_subproc_atom_uncaptured(self, p):
"""subproc_atom : dollar_lbracket_tok subproc RBRACKET"""
p1 = p[1]
p0 = xonsh_call(
"__xonsh__.subproc_uncaptured", args=p[2], lineno=p1.lineno, col=p1.lexpos
)
p0._cliarg_action = "splitlines"
p[0] = p0
else:
lineno, col = self.lineno, self.col
if lenp == 3: # $NAME
p0 = self._envvar_by_name(p2, lineno=lineno, col=col)
elif p1 == "${":
xenv = load_attribute_chain("__xonsh__.env", lineno=lineno, col=col)
idx = ast.Index(value=p2)
p0 = ast.Subscript(
value=xenv, slice=idx, ctx=ast.Load(), lineno=lineno, col_offset=col
)
elif p1 == "$(":
p0 = xonsh_call(
"__xonsh__.subproc_captured_stdout", p2, lineno=lineno, col=col
)
elif p1 == "!(":
p0 = xonsh_call(
"__xonsh__.subproc_captured_object", p2, lineno=lineno, col=col
)
elif p1 == "![":
p0 = xonsh_call(
"__xonsh__.subproc_captured_hiddenobject", p2, lineno=lineno, col=col
)
elif p1 == "$[":
p0 = xonsh_call("__xonsh__.subproc_uncaptured", p2, lineno=lineno, col=col)
else:
assert False
return p0