1313SOURCE_FOLDER = os .path .join (REPO_DIR , "src" , "original" )
1414WRAPPED_FOLDER = os .path .join (REPO_DIR , "src" , "standardized" )
1515
16- # Read the CSV file
17- df = pd .read_csv (CODE_CONTRIBUTIONS_FILE )
16+ def generate_html ():
17+ """
18+ Generates an HTML report based on the code contributions and algorithm information.
1819
19- unique_subfolders = df ['subfolder' ].unique ().tolist ()
20+ The report includes the following columns:
21+ - Technique
22+ - Subfolder
23+ - Contributors
24+ - Wrapped
25+ - Tested
2026
21- # Read the JSON file
22- with open (ALGORITHMS_FILE , 'r' ) as f :
23- algorithms_data = json .load (f )
27+ The report is saved as 'combined_report.html' in the 'website' directory of the repository.
28+ """
29+ # Read the CSV file
30+ df = pd .read_csv (CODE_CONTRIBUTIONS_FILE )
2431
25- # list of all algorithms from the JSON file
26- all_algorithms = algorithms_data ['algorithms' ]
32+ unique_subfolders = df ['subfolder' ].unique ().tolist ()
2733
28- # Check if both code_contributions_file matches with source folder
29- for subfolder in unique_subfolders :
30- subfolder_path = os .path .join (SOURCE_FOLDER , subfolder )
31- if not os .path .exists (subfolder_path ):
32- print (f"Warning: Subfolder '{ subfolder } ' does not exist in the source folder." )
34+ # Read the JSON file
35+ with open (ALGORITHMS_FILE , 'r' ) as f :
36+ algorithms_data = json .load (f )
3337
34- # Add column 'Tested' to the DataFrame based on a match with algorithms and wrapped column
35- df ['Wrapped' ] = df ['Wrapped' ].fillna ('' )
36- df ['Tested' ] = df .apply (lambda row : 'Yes' if any (algorithm in row ['Wrapped' ] for algorithm in all_algorithms ) else '' , axis = 1 )
38+ # list of all algorithms from the JSON file
39+ all_algorithms = algorithms_data ['algorithms' ]
3740
38- # Select the desired columns
39- df_selected = df [['Technique' , 'subfolder' , 'Authors' , 'Wrapped' , 'Tested' ]]
40- df_selected .columns = ['Technique' , 'Subfolder' , 'Contributors' , 'Wrapped' , 'Tested' ]
41+ # Check if both code_contributions_file matches with source folder
42+ for subfolder in unique_subfolders :
43+ subfolder_path = os .path .join (SOURCE_FOLDER , subfolder )
44+ if not os .path .exists (subfolder_path ):
45+ print (f"Warning: Subfolder '{ subfolder } ' does not exist in the source folder." )
4146
42- # Convert the DataFrame to HTML
43- html_string = df_selected .to_html (index = False )
47+ # Add column 'Tested' to the DataFrame based on a match with algorithms and wrapped column
48+ df ['Wrapped' ] = df ['Wrapped' ].fillna ('' )
49+ df ['Tested' ] = df .apply (lambda row : 'Yes' if any (algorithm in row ['Wrapped' ] for algorithm in all_algorithms ) else '' , axis = 1 )
4450
45- # Save the HTML to a file
46- with open ( os . path . join ( REPO_DIR , 'website' , 'combined_report.html' ) , 'w' ) as f :
47- f . write ( html_string )
51+ # Select the desired columns
52+ df_selected = df [[ 'Technique' , 'subfolder' , 'Authors' , 'Wrapped' , 'Tested' ]]
53+ df_selected . columns = [ 'Technique' , 'Subfolder' , 'Contributors' , 'Wrapped' , 'Tested' ]
4854
49- # Printing message that report has been successfully generated
50- print ("Combined HTML report generated successfully." )
55+ # Convert the DataFrame to HTML
56+ html_string = df_selected .to_html (index = False )
57+
58+ # Save the HTML to a file
59+ with open (os .path .join (REPO_DIR , 'website' , 'combined_report.html' ), 'w' ) as f :
60+ f .write (html_string )
61+
62+ # Printing message that report has been successfully generated
63+ print ("Combined HTML report generated successfully." )
64+
65+ if __name__ == "__main__" :
66+ generate_html ()
0 commit comments