<s> import re <EOL> from django . template . loader import render_to_string <EOL> from tasks . const import STATUS_SUCCESS , STATUS_FAILED <EOL> from . base import library <EOL> @ library . register ( '<STR_LIT>' ) <EOL> def jslint_violation ( data ) : <EOL> """<STR_LIT>""" <EOL> stripped = [ <EOL> line . strip ( ) if <NUM_LIT:0> <= line . find ( '<STR_LIT:#>' ) < <NUM_LIT:5> else line <EOL> for line in data [ '<STR_LIT>' ] . split ( '<STR_LIT:\n>' ) if line <EOL> ] <EOL> count = len ( [ line . find ( '<STR_LIT:#>' ) == <NUM_LIT:0> for line in stripped ] ) <EOL> data [ '<STR_LIT:status>' ] = STATUS_SUCCESS if count == <NUM_LIT:0> else STATUS_FAILED <EOL> data [ '<STR_LIT>' ] = render_to_string ( '<STR_LIT>' , { <EOL> '<STR_LIT:count>' : count , <EOL> } ) <EOL> data [ '<STR_LIT>' ] = [ ] <EOL> files = [ ] <EOL> for line in stripped : <EOL> if line [ <NUM_LIT:0> ] not in ( '<STR_LIT:#>' , '<STR_LIT:U+0020>' ) : <EOL> if '<STR_LIT>' in line : <EOL> files . append ( [ line . split ( '<STR_LIT:U+0020>' ) [ <NUM_LIT:0> ] , True , [ ] ] ) <EOL> else : <EOL> files . append ( [ line , False , [ ] ] ) <EOL> elif line [ <NUM_LIT:0> ] == '<STR_LIT:#>' : <EOL> files [ - <NUM_LIT:1> ] [ <NUM_LIT:2> ] . append ( [ line , [ ] ] ) <EOL> elif line . find ( '<STR_LIT:U+0020>' ) == <NUM_LIT:0> : <EOL> files [ - <NUM_LIT:1> ] [ <NUM_LIT:2> ] [ - <NUM_LIT:1> ] [ <NUM_LIT:1> ] . append ( line . strip ( ) ) <EOL> line_match = re . match ( r'<STR_LIT>' , line ) <EOL> if line_match : <EOL> line , position = line_match . groups ( ) <EOL> error_title = re . match ( <EOL> r'<STR_LIT>' , files [ - <NUM_LIT:1> ] [ <NUM_LIT:2> ] [ - <NUM_LIT:1> ] [ <NUM_LIT:0> ] , <EOL> ) . groups ( ) [ <NUM_LIT:0> ] <EOL> data [ '<STR_LIT>' ] . append ( { <EOL> '<STR_LIT:body>' : error_title , <EOL> '<STR_LIT>' : int ( line ) , <EOL> '<STR_LIT:path>' : files [ - <NUM_LIT:1> ] [ <NUM_LIT:0> ] , <EOL> '<STR_LIT>' : int ( position ) , <EOL> } ) <EOL> data [ '<STR_LIT>' ] = render_to_string ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : files , <EOL> } ) <EOL> data [ '<STR_LIT>' ] = { <EOL> '<STR_LIT:count>' : count , <EOL> } <EOL> return data </s>
