<s> import os , re <EOL> attribute_regex = re . compile ( "<STR_LIT>" , re . I ) <EOL> end_tag_regex = re . compile ( "<STR_LIT>" , re . I ) <EOL> alt_end_tag_regex = re . compile ( "<STR_LIT>" ) <EOL> def index ( custom_tag_path ) : <EOL> custom_tags = { } <EOL> for path in os . listdir ( custom_tag_path ) : <EOL> if path . endswith ( "<STR_LIT>" ) or path . endswith ( "<STR_LIT>" ) : <EOL> full_file_path = custom_tag_path . replace ( "<STR_LIT:\\>" , "<STR_LIT:/>" ) + '<STR_LIT:/>' + path <EOL> custom_tags [ full_file_path ] = index_file ( full_file_path ) <EOL> return custom_tags <EOL> def index_file ( full_file_path ) : <EOL> try : <EOL> with open ( full_file_path , '<STR_LIT:r>' ) as f : <EOL> file_string = f . read ( ) <EOL> except : <EOL> print ( "<STR_LIT>" + full_file_path ) <EOL> return { } <EOL> file_index = { "<STR_LIT>" : full_file_path . split ( "<STR_LIT:/>" ) . pop ( ) [ : - <NUM_LIT:4> ] } <EOL> file_index . update ( parse_cfm_file_string ( file_string ) ) <EOL> return file_index <EOL> def parse_cfm_file_string ( file_string ) : <EOL> tag_index = { "<STR_LIT>" : False } <EOL> tag_index [ "<STR_LIT>" ] = list ( sorted ( set ( [ attr . lower ( ) for attr in re . findall ( attribute_regex , file_string ) ] ) ) ) <EOL> if re . search ( end_tag_regex , file_string ) : <EOL> tag_index [ "<STR_LIT>" ] = True <EOL> elif re . search ( alt_end_tag_regex , file_string ) : <EOL> tag_index [ "<STR_LIT>" ] = True <EOL> return tag_index </s>
