'Checks for a variety of violations:
- Checks that format() calls with nested HTML() or Text() calls use
HTML() or Text() on the left-hand side.
- For each HTML() and Text() call, calls into separate visitor to check
for inner format() calls.
Arguments:
node: An AST node.'

def visit_Call(self, node):

    if (isinstance(node.func, ast.Attribute) and (node.func.attr == 'format')):
        visitor = FormatInterpolateVisitor(self.file_contents, self.results)
        visitor.visit(node)
        if visitor.interpolates_text_or_html:
            format_caller = node.func.value
            is_caller_html_or_text = (isinstance(format_caller, ast.Call) and isinstance(format_caller.func, ast.Name) and (format_caller.func.id in ['Text', 'HTML']))
            if (is_caller_html_or_text is False):
                self.results.violations.append(ExpressionRuleViolation(Rules.python_requires_html_or_text, self.node_to_expression(node.func)))
    elif (isinstance(node.func, ast.Name) and (node.func.id in ['HTML', 'Text'])):
        visitor = ContainsFormatVisitor(self.file_contents, self.results)
        visitor.visit(node)
        if visitor.contains_format_call:
            self.results.violations.append(ExpressionRuleViolation(Rules.python_close_before_format, self.node_to_expression(node.func)))
    self.generic_visit(node)
