<s> import ast <EOL> from . base import BaseAnalyzer , Result <EOL> DESCRIPTION = """<STR_LIT>""" <EOL> class DB_BackendsVisitor ( ast . NodeVisitor ) : <EOL> def __init__ ( self ) : <EOL> self . found = [ ] <EOL> removed_items = { <EOL> '<STR_LIT>' : <EOL> '<STR_LIT>' , <EOL> } <EOL> def visit_Str ( self , node ) : <EOL> if node . s in self . removed_items . keys ( ) : <EOL> self . found . append ( ( node . s , node ) ) <EOL> class DB_BackendsAnalyzer ( BaseAnalyzer ) : <EOL> def analyze_file ( self , filepath , code ) : <EOL> if not isinstance ( code , ast . AST ) : <EOL> return <EOL> visitor = DB_BackendsVisitor ( ) <EOL> visitor . visit ( code ) <EOL> for name , node in visitor . found : <EOL> propose = visitor . removed_items [ name ] <EOL> result = Result ( <EOL> description = DESCRIPTION . format ( name = name , propose = propose ) , <EOL> path = filepath , <EOL> line = node . lineno ) <EOL> lines = self . get_file_lines ( filepath , node . lineno , node . lineno ) <EOL> for lineno , important , text in lines : <EOL> result . source . add_line ( lineno , text , important ) <EOL> result . solution . add_line ( lineno , text . replace ( name , propose ) , important ) <EOL> yield result </s>
