text stringlengths 0 828 |
|---|
[self.__visit_target(x) for x in node.elts]" |
404,"def __get_package_manager(self): |
"""""" |
Installs and verifies package manager |
"""""" |
package_manager = """" |
args = """" |
sudo_required = True |
if system.is_osx(): |
package_manager = ""brew"" |
sudo_required = False |
args = "" install"" |
elif system.is_debian(): |
package_manager = ""apt-get"" |
args = "" -y install"" |
elif system.is_fedora(): |
package_manager = ""yum"" |
args = "" install"" |
elif system.is_arch(): |
package_manager = ""pacman"" |
args = "" --noconfirm -S"" |
if lib.which(package_manager) is None: |
self.logger.warn(""Package manager %s not installed! Packages will not be installed."" |
% package_manager) |
self.package_manager = None |
self.package_manager = package_manager |
self.sudo_required = sudo_required |
self.args = args" |
405,"def eval_expr(expr, context): |
""""""Recursively evaluates a compiled expression using the specified context. |
Dict instances can contain a ""__kwargs"" key which will be used to update the |
dict with its content |
"""""" |
if isinstance(expr, list): |
rv = [] |
for item in expr: |
rv.append(eval_expr(item, context)) |
return rv |
if isinstance(expr, dict): |
rv = {} |
for k, v in expr.iteritems(): |
rv[k] = eval_expr(v, context) |
kwargs = rv.pop(""__kwargs"", None) |
if kwargs: |
rv.update(kwargs) |
return rv |
if isinstance(expr, Expression): |
return expr.eval(context) |
return expr" |
406,"def can_convert(strict: bool, from_type: Type[S], to_type: Type[T]): |
"""""" |
None should be treated as a Joker here (but we know that never from_type and to_type will be None at the same time) |
:param strict: |
:param from_type: |
:param to_type: |
:return: |
"""""" |
if (to_type is not None) and (to_type not in (all_primitive_types + all_np_primitive_types)): |
return False |
else: |
return True" |
407,"def parse(self, data, doctype): |
''' |
Parse an input string, and return an AST |
doctype must have WCADocument as a baseclass |
''' |
self.doctype = doctype |
self.lexer.lineno = 0 |
del self.errors[:] |
del self.warnings[:] |
self.lexer.lexerror = False |
ast = self.parser.parse(data, lexer=self.lexer) |
if self.lexer.lexerror: |
ast = None |
if ast is None: |
self.errors.append(""Couldn't build AST."") |
else: |
for check in self.sema[self.doctype]: |
visitor = check() |
if not visitor.visit(ast): |
self.errors.append(""Couldn't visit AST."") |
self.errors.extend(visitor.errors) |
self.warnings.extend(visitor.warnings) |
return (ast, list(self.errors), list(self.warnings))" |
408,"def _act_on_list(self, lhs): |
''' |
Act on the following rule : |
items : items item |
| item |
''' |
lhs[0] = [] |
if len(lhs) == 3: |
lhs[0] = lhs[1] |
# lhs[len(lhs)-1] may be different from lhs[-1] |
# Yacc use some internal method to get the element, see yacc.py:240 |
item = lhs[len(lhs) - 1] |
if item: |
lhs[0].append(item)" |
409,"def p_content(self, content): |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.