<s> __author__ = '<STR_LIT>' <EOL> from git import * <EOL> import re <EOL> from datetime import datetime <EOL> class GitQuerier ( ) : <EOL> ALLOWED_EXTENSION = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:html>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:c>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:rb>' , '<STR_LIT:m>' ] <EOL> def __init__ ( self , git_repo_path , logger ) : <EOL> self . logger = logger <EOL> self . repo = Repo ( git_repo_path ) <EOL> self . no_treated_extensions = set ( ) <EOL> def get_diffs ( self , commit ) : <EOL> return commit . parents [ <NUM_LIT:0> ] . diff ( commit , create_patch = True ) <EOL> def commit_has_no_parents ( self , commit ) : <EOL> flag = False ; <EOL> if not commit . parents : <EOL> flag = True <EOL> return flag <EOL> def get_files_in_ref ( self , ref ) : <EOL> files = [ ] <EOL> git = self . repo . git <EOL> content = git . execute ( [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> for line in content . split ( "<STR_LIT:\n>" ) : <EOL> files . append ( line ) <EOL> return files <EOL> def get_diffs_no_parent_commit ( self , commit ) : <EOL> diffs = [ ] <EOL> content = self . repo . git . execute ( [ "<STR_LIT>" , "<STR_LIT>" , commit . hexsha ] ) <EOL> lines = content . split ( '<STR_LIT:\n>' ) <EOL> flag = False <EOL> file_a = None <EOL> for line in lines : <EOL> if re . match ( "<STR_LIT>" , line ) : <EOL> line_content = re . sub ( "<STR_LIT>" , "<STR_LIT>" , line ) <EOL> if file_a : <EOL> diffs . append ( ( file_a , content ) ) <EOL> flag = False <EOL> file_a = line_content . split ( '<STR_LIT:U+0020>' ) [ <NUM_LIT:0> ] . replace ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> elif re . match ( "<STR_LIT>" , line ) : <EOL> if not flag : <EOL> flag = True <EOL> content = line <EOL> else : <EOL> diffs . append ( ( file_a , content ) ) <EOL> content = line <EOL> elif flag : <EOL> if line != '<STR_LIT>' : <EOL> content = content + '<STR_LIT:\n>' + line <EOL> if file_a : <EOL> diffs . append ( ( file_a , content ) ) <EOL> else : <EOL> self . logger . warning ( "<STR_LIT>" ) <EOL> return diffs <EOL> def get_status ( self , stats , diff ) : <EOL> additions = stats [ <NUM_LIT:0> ] <EOL> deletions = stats [ <NUM_LIT:1> ] <EOL> if additions > <NUM_LIT:0> and deletions == <NUM_LIT:0> : <EOL> status = "<STR_LIT>" <EOL> elif additions == <NUM_LIT:0> and deletions > <NUM_LIT:0> : <EOL> status = "<STR_LIT>" <EOL> elif additions > <NUM_LIT:0> and deletions > <NUM_LIT:0> : <EOL> status = "<STR_LIT>" <EOL> else : <EOL> try : <EOL> if diff . new_file : <EOL> status = "<STR_LIT>" <EOL> elif diff . deleted_file : <EOL> status = "<STR_LIT>" <EOL> elif additions == <NUM_LIT:0> and deletions == <NUM_LIT:0> : <EOL> status = "<STR_LIT>" <EOL> self . logger . warning ( "<STR_LIT>" ) <EOL> else : <EOL> status = "<STR_LIT>" <EOL> except : <EOL> status = "<STR_LIT>" <EOL> return status <EOL> def is_renamed ( self , diff ) : <EOL> flag = False <EOL> if diff . renamed : <EOL> flag = True <EOL> elif ( not diff . a_blob ) and ( not diff . b_blob ) : <EOL> if re . match ( r"<STR_LIT>" , diff . diff , re . M ) : <EOL> flag = True <EOL> return flag <EOL> def get_stats_for_file ( self , commit , file_name ) : <EOL> stats_for_file = ( ) <EOL> for f in commit . stats . files . keys ( ) : <EOL> if f == file_name : <EOL> stats = commit . stats . files . get ( f ) <EOL> stats_for_file = ( stats . get ( '<STR_LIT>' ) , stats . get ( '<STR_LIT>' ) , stats . get ( '<STR_LIT>' ) ) <EOL> if not stats_for_file : <EOL> stats_for_file = ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> self . logger . warning ( "<STR_LIT>" + file_name + "<STR_LIT>" ) <EOL> return stats_for_file <EOL> def get_references ( self ) : <EOL> references = [ ] <EOL> for ref in self . repo . references : <EOL> if type ( ref ) == RemoteReference : <EOL> if ref . name != "<STR_LIT>" : <EOL> references . append ( ( ref . name , '<STR_LIT>' ) ) <EOL> elif type ( ref ) == TagReference : <EOL> references . append ( ( ref . name , '<STR_LIT>' ) ) <EOL> else : <EOL> self . logger . warning ( "<STR_LIT>" + str ( type ( ref ) ) + "<STR_LIT>" ) <EOL> return references <EOL> def get_commits ( self , ref_name ) : <EOL> commits = [ ] <EOL> for commit in self . repo . iter_commits ( rev = ref_name ) : <EOL> commits . append ( commit ) <EOL> return commits <EOL> def get_commits_before_date ( self , commits , date ) : <EOL> before_date_object = datetime . strptime ( date , "<STR_LIT>" ) <EOL> selected_commits = [ ] <EOL> for commit in commits : <EOL> committed_date_object = datetime . fromtimestamp ( commit . committed_date ) <EOL> if committed_date_object <= before_date_object : <EOL> selected_commits . append ( commit ) <EOL> return selected_commits <EOL> def get_commits_after_sha ( self , commits , sha ) : <EOL> selected_commits = [ ] <EOL> for commit in commits : <EOL> if commit . hexsha == sha : <EOL> break <EOL> else : <EOL> selected_commits . append ( commit ) <EOL> return selected_commits <EOL> def order_chronologically_commits ( self , commits ) : <EOL> commits . reverse ( ) <EOL> return commits <EOL> def collect_all_commits ( self , ref_name ) : <EOL> commits = self . get_commits ( ref_name ) <EOL> ordered = self . order_chronologically_commits ( commits ) <EOL> return ordered <EOL> def collect_all_commits_before_date ( self , ref_name , date ) : <EOL> commits = self . get_commits ( ref_name ) <EOL> selected_commits = self . get_commits_before_date ( commits , date ) <EOL> ordered = self . order_chronologically_commits ( selected_commits ) <EOL> return ordered <EOL> def collect_all_commits_after_sha ( self , ref_name , sha ) : <EOL> commits = self . get_commits ( ref_name ) <EOL> selected_commits = self . get_commits_after_sha ( commits , sha ) <EOL> ordered = self . order_chronologically_commits ( selected_commits ) <EOL> return ordered <EOL> def collect_all_commits_after_sha_before_date ( self , ref_name , sha , before_date ) : <EOL> commits = self . get_commits ( ref_name ) <EOL> selected_commits = self . get_commits_after_sha ( commits , sha ) <EOL> selected_commits = self . get_commits_before_date ( selected_commits , before_date ) <EOL> ordered = self . order_chronologically_commits ( selected_commits ) <EOL> return ordered <EOL> def get_line_content ( self , patch_content , line_number ) : <EOL> content = "<STR_LIT>" <EOL> content_list = [ ] <EOL> lines = patch_content . split ( '<STR_LIT:\n>' ) <EOL> original_line = <NUM_LIT:0> <EOL> new_line = <NUM_LIT:0> <EOL> original_end = <NUM_LIT:0> <EOL> new_end = <NUM_LIT:0> <EOL> last_content_added = "<STR_LIT>" <EOL> for line in lines : <EOL> if re . match ( r"<STR_LIT>" , line , re . M ) : <EOL> begin = self . get_file_modification_begin ( line ) <EOL> original_line = begin [ <NUM_LIT:0> ] <EOL> new_line = begin [ <NUM_LIT:1> ] <EOL> end = self . get_file_modification_end ( line ) <EOL> deletion_end = end [ <NUM_LIT:0> ] <EOL> addition_end = end [ <NUM_LIT:1> ] <EOL> else : <EOL> if deletion_end > line_number : <EOL> if len ( content_list ) == <NUM_LIT:2> : <EOL> break <EOL> if original_line > line_number and new_line > line_number : <EOL> break <EOL> else : <EOL> if new_line > line_number : <EOL> break <EOL> if re . match ( r"<STR_LIT>" , line , re . M ) : <EOL> if new_line == line_number : <EOL> content_list . append ( { '<STR_LIT:type>' : '<STR_LIT>' , '<STR_LIT:text>' : line [ <NUM_LIT:1> : ] } ) <EOL> last_content_added = '<STR_LIT>' <EOL> new_line += <NUM_LIT:1> <EOL> elif re . match ( r"<STR_LIT>" , line , re . M ) : <EOL> if original_line == line_number : <EOL> content_list . append ( { '<STR_LIT:type>' : '<STR_LIT>' , '<STR_LIT:text>' : line [ <NUM_LIT:1> : ] } ) <EOL> last_content_added = '<STR_LIT>' <EOL> original_line += <NUM_LIT:1> <EOL> else : <EOL> if line != '<STR_LIT>' and line != '<STR_LIT>' : <EOL> original_line += <NUM_LIT:1> <EOL> new_line += <NUM_LIT:1> <EOL> if content_list : <EOL> content = content_list [ - <NUM_LIT:1> ] <EOL> return content <EOL> def get_line_details ( self , patch_content , file_extension ) : <EOL> details = [ ] <EOL> block_comment = False <EOL> previous_block_comment = False <EOL> lines = patch_content . split ( '<STR_LIT:\n>' ) <EOL> previous_original_line = <NUM_LIT:0> <EOL> previous_new_line = <NUM_LIT:0> <EOL> original_line = <NUM_LIT:0> <EOL> new_line = <NUM_LIT:0> <EOL> for line in lines : <EOL> is_commented = False <EOL> is_partially_commented = False <EOL> is_empty = False <EOL> is_documentation = False <EOL> if re . match ( r"<STR_LIT>" , line , re . M ) : <EOL> begin = self . get_file_modification_begin ( line ) <EOL> original_line = begin [ <NUM_LIT:0> ] <EOL> new_line = begin [ <NUM_LIT:1> ] <EOL> if block_comment : <EOL> previous_block_comment = True <EOL> else : <EOL> previous_block_comment = False <EOL> block_comment = False <EOL> else : <EOL> if re . match ( r"<STR_LIT>" , line , re . M ) : <EOL> if self . line_is_empty ( line ) : <EOL> self . add_to_details ( details , "<STR_LIT>" , new_line , False , False , True , line ) <EOL> else : <EOL> if file_extension in GitQuerier . ALLOWED_EXTENSION : <EOL> result = self . line_is_commented ( "<STR_LIT>" , previous_block_comment , previous_new_line , new_line , block_comment , details , line , file_extension ) <EOL> details = result [ <NUM_LIT:0> ] <EOL> previous_block_comment = result [ <NUM_LIT:1> ] <EOL> block_comment = result [ <NUM_LIT:2> ] <EOL> is_commented = result [ <NUM_LIT:3> ] <EOL> is_partially_commented = result [ <NUM_LIT:4> ] <EOL> self . add_to_details ( details , "<STR_LIT>" , new_line , is_commented , is_partially_commented , False , line ) <EOL> previous_new_line = new_line <EOL> new_line += <NUM_LIT:1> <EOL> elif re . match ( r"<STR_LIT>" , line , re . M ) : <EOL> if self . line_is_empty ( line ) : <EOL> self . add_to_details ( details , "<STR_LIT>" , original_line , False , False , True , line ) <EOL> else : <EOL> if file_extension in GitQuerier . ALLOWED_EXTENSION : <EOL> result = self . line_is_commented ( "<STR_LIT>" , previous_block_comment , previous_original_line , original_line , block_comment , details , line , file_extension ) <EOL> details = result [ <NUM_LIT:0> ] <EOL> previous_block_comment = result [ <NUM_LIT:1> ] <EOL> block_comment = result [ <NUM_LIT:2> ] <EOL> is_commented = result [ <NUM_LIT:3> ] <EOL> is_partially_commented = result [ <NUM_LIT:4> ] <EOL> self . add_to_details ( details , "<STR_LIT>" , original_line , is_commented , is_partially_commented , False , line ) <EOL> previous_original_line = original_line <EOL> original_line += <NUM_LIT:1> <EOL> else : <EOL> if line != '<STR_LIT>' and line != '<STR_LIT>' : <EOL> original_line += <NUM_LIT:1> <EOL> new_line += <NUM_LIT:1> <EOL> return details <EOL> def add_no_treated_extensions_to_log ( self ) : <EOL> for ext in list ( self . no_treated_extensions ) : <EOL> self . logger . warning ( "<STR_LIT>" + str ( ext ) + "<STR_LIT>" ) <EOL> return <EOL> def line_is_commented ( self , type_change , previous_block_comment , previous_line_number , current_line_number , block_comment , details , line , file_extension ) : <EOL> is_commented = False <EOL> is_partially_commented = False <EOL> if previous_block_comment : <EOL> for i in range ( previous_line_number , current_line_number ) : <EOL> self . add_to_details ( details , type_change , i , True , False , False , None ) <EOL> previous_block_comment = False <EOL> block_comment = self . line_is_in_block_comment ( block_comment , line , file_extension ) <EOL> if self . line_is_fully_commented ( line , file_extension ) or block_comment or previous_block_comment or self . line_contains_only_close_block_comment ( line , file_extension ) or self . line_ends_with_close_block_comment ( line , file_extension ) : <EOL> is_commented = True <EOL> elif self . line_is_partially_commented ( line , file_extension ) or self . line_contains_open_block_comment ( line , file_extension ) or self . line_contains_close_block_comment ( line , file_extension ) : <EOL> is_partially_commented = True <EOL> block_comment = self . line_is_partially_in_block_comment ( block_comment , line , file_extension ) <EOL> return ( details , previous_block_comment , block_comment , is_commented , is_partially_commented ) <EOL> def get_file_modification_begin ( self , line ) : <EOL> modified_lines = line . split ( "<STR_LIT>" ) [ <NUM_LIT:1> ] . strip ( ) . split ( "<STR_LIT:U+0020>" ) <EOL> original_starting = modified_lines [ <NUM_LIT:0> ] <EOL> original_line = int ( original_starting . split ( '<STR_LIT:U+002C>' ) [ <NUM_LIT:0> ] . replace ( '<STR_LIT:->' , '<STR_LIT>' ) ) <EOL> new_starting = modified_lines [ <NUM_LIT:1> ] <EOL> new_line = int ( new_starting . split ( '<STR_LIT:U+002C>' ) [ <NUM_LIT:0> ] . replace ( '<STR_LIT:+>' , '<STR_LIT>' ) ) <EOL> return original_line , new_line <EOL> def get_file_modification_end ( self , line ) : <EOL> modified_lines = line . split ( "<STR_LIT>" ) [ <NUM_LIT:1> ] . strip ( ) . split ( "<STR_LIT:U+0020>" ) <EOL> original_ending = modified_lines [ <NUM_LIT:0> ] <EOL> original_line = int ( original_ending . split ( '<STR_LIT:U+002C>' ) [ <NUM_LIT:1> ] ) <EOL> new_ending = modified_lines [ <NUM_LIT:1> ] <EOL> try : <EOL> new_line = int ( new_ending . split ( '<STR_LIT:U+002C>' ) [ <NUM_LIT:1> ] ) <EOL> except : <EOL> new_line = <NUM_LIT:0> <EOL> return original_line , new_line <EOL> def add_to_details ( self , details , type , line , is_commented , is_partially_commented , is_empty , line_content ) : <EOL> details . append ( ( type , line , is_commented , is_partially_commented , is_empty , line_content ) ) <EOL> return <EOL> def line_is_empty ( self , line ) : <EOL> flag = False <EOL> if re . match ( r"<STR_LIT>" , line , re . M ) : <EOL> flag = True <EOL> return flag <EOL> def line_starts_with_open_block_comment ( self , line , ext ) : <EOL> flag = False <EOL> if ext in ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:c>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) : <EOL> if re . match ( r"<STR_LIT>" , line ) and not re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext == "<STR_LIT>" : <EOL> if re . match ( r'<STR_LIT>' , line ) and not re . match ( r'<STR_LIT>' , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT>" , "<STR_LIT:html>" ) : <EOL> if re . match ( r'<STR_LIT>' , line ) and not re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT:rb>" ) : <EOL> if re . match ( r'<STR_LIT>' , line ) and not re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT:m>" ) : <EOL> if re . match ( r'<STR_LIT>' , line ) and not re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> return flag <EOL> def line_contains_only_open_block_comment ( self , line , ext ) : <EOL> flag = False <EOL> if ext in ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:c>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) : <EOL> if re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext == "<STR_LIT>" : <EOL> if re . match ( r'<STR_LIT>' , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT>" , "<STR_LIT:html>" ) : <EOL> if re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT:rb>" ) : <EOL> if re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT:m>" ) : <EOL> if re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> return flag <EOL> def line_contains_open_block_comment ( self , line , ext ) : <EOL> flag = False <EOL> if ext in ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:c>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) : <EOL> if re . match ( r"<STR_LIT>" , line ) and not re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext == "<STR_LIT>" : <EOL> if re . match ( r'<STR_LIT>' , line ) and not re . match ( r'<STR_LIT>' , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT>" , "<STR_LIT:html>" ) : <EOL> if re . match ( r'<STR_LIT>' , line ) and not re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT:rb>" ) : <EOL> if re . match ( r'<STR_LIT>' , line ) and not re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT:m>" ) : <EOL> if re . match ( r'<STR_LIT>' , line ) and not re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> return flag <EOL> def line_ends_with_close_block_comment ( self , line , ext ) : <EOL> flag = False <EOL> if ext in ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:c>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) : <EOL> if re . match ( r"<STR_LIT>" , line ) and not re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext == "<STR_LIT>" : <EOL> if re . match ( r'<STR_LIT>' , line ) and not re . match ( r'<STR_LIT>' , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT>" , "<STR_LIT:html>" ) : <EOL> if re . match ( r"<STR_LIT>" , line ) and not re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT:rb>" ) : <EOL> if re . match ( r'<STR_LIT>' , line ) and not re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT:m>" ) : <EOL> if re . match ( r'<STR_LIT>' , line ) and not re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> return flag <EOL> def line_starts_with_close_block_comment ( self , line , ext ) : <EOL> flag = False <EOL> if ext in ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:c>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) : <EOL> if re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext == "<STR_LIT>" : <EOL> if re . match ( r'<STR_LIT>' , line ) and not re . match ( r'<STR_LIT>' , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT>" , "<STR_LIT:html>" ) : <EOL> if re . match ( r'<STR_LIT>' , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT:rb>" ) : <EOL> if re . match ( r'<STR_LIT>' , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT:m>" ) : <EOL> if re . match ( r'<STR_LIT>' , line ) : <EOL> flag = True <EOL> return flag <EOL> def line_contains_only_close_block_comment ( self , line , ext ) : <EOL> flag = False <EOL> if ext in ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:c>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) : <EOL> if re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext == "<STR_LIT>" : <EOL> if re . match ( r'<STR_LIT>' , line ) and not re . match ( r'<STR_LIT>' , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT>" , "<STR_LIT:html>" ) : <EOL> if re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT:rb>" ) : <EOL> if re . match ( r'<STR_LIT>' , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT:m>" ) : <EOL> if re . match ( r'<STR_LIT>' , line ) : <EOL> flag = True <EOL> return flag <EOL> def line_contains_close_block_comment ( self , line , ext ) : <EOL> flag = False <EOL> if ext in ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:c>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) : <EOL> if re . match ( r"<STR_LIT>" , line ) and not re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext == "<STR_LIT>" : <EOL> if re . match ( r'<STR_LIT>' , line ) and not re . match ( r'<STR_LIT>' , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT>" , "<STR_LIT:html>" ) : <EOL> if re . match ( r'<STR_LIT>' , line ) and not re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT:rb>" ) : <EOL> if re . match ( r'<STR_LIT>' , line ) and not re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT:m>" ) : <EOL> if re . match ( r'<STR_LIT>' , line ) and not re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> return flag <EOL> def line_is_partially_commented ( self , line , ext ) : <EOL> flag = False <EOL> if ext in ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:c>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) : <EOL> if re . match ( r"<STR_LIT>" , line ) or re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT>" , "<STR_LIT:rb>" ) : <EOL> if re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT>" , "<STR_LIT:html>" ) : <EOL> if re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext == "<STR_LIT>" : <EOL> if re . match ( r"<STR_LIT>" , line ) or re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext == "<STR_LIT>" : <EOL> if re . match ( r"<STR_LIT>" , line ) or re . match ( r"<STR_LIT>" , line ) or re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext == "<STR_LIT:m>" : <EOL> if re . match ( r'<STR_LIT>' , line ) or re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> else : <EOL> self . logger . warning ( "<STR_LIT>" + ext ) <EOL> return flag <EOL> def line_is_fully_commented ( self , line , ext ) : <EOL> flag = False <EOL> if ext in ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:c>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) : <EOL> if re . match ( r"<STR_LIT>" , line ) or re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT>" , "<STR_LIT:rb>" ) : <EOL> if re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext in ( "<STR_LIT>" , "<STR_LIT:html>" ) : <EOL> if re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext == "<STR_LIT>" : <EOL> if re . match ( r"<STR_LIT>" , line ) or re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext == "<STR_LIT>" : <EOL> if re . match ( r"<STR_LIT>" , line ) or re . match ( r"<STR_LIT>" , line ) or re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> elif ext == "<STR_LIT:m>" : <EOL> if re . match ( r'<STR_LIT>' , line ) or re . match ( r"<STR_LIT>" , line ) : <EOL> flag = True <EOL> else : <EOL> self . logger . warning ( "<STR_LIT>" + ext ) <EOL> return flag <EOL> def line_is_in_block_comment ( self , block_comment , line , ext ) : <EOL> if not block_comment : <EOL> if self . line_starts_with_open_block_comment ( line , ext ) or self . line_contains_only_open_block_comment ( line , ext ) : <EOL> block_comment = True <EOL> else : <EOL> if self . line_ends_with_close_block_comment ( line , ext ) or self . line_contains_only_close_block_comment ( line , ext ) or self . line_starts_with_close_block_comment ( line , ext ) : <EOL> block_comment = False <EOL> return block_comment <EOL> def line_is_partially_in_block_comment ( self , block_comment , line , ext ) : <EOL> if not block_comment : <EOL> if self . line_contains_open_block_comment ( line , ext ) : <EOL> block_comment = True <EOL> else : <EOL> if self . line_contains_close_block_comment ( line , ext ) : <EOL> block_comment = False <EOL> return block_comment </s>
