diff --git a/docs/devices/devices_template.html b/docs/devices/devices_template.html index 8b9106af..1a6bd081 100644 --- a/docs/devices/devices_template.html +++ b/docs/devices/devices_template.html @@ -1,6 +1,61 @@ + + @@ -17,61 +72,6 @@ - - diff --git a/docs/devices/generate_devices_tables.py b/docs/devices/generate_devices_tables.py index 3b7ea343..e355a0d2 100644 --- a/docs/devices/generate_devices_tables.py +++ b/docs/devices/generate_devices_tables.py @@ -12,13 +12,11 @@ file_app = "devices.md" http_file_app = "https://github.com/theengs/app/raw/development/docs/prerequisites/devices.md" -# Loading of the template file with the list of attributes logger.info('Loading template file: %s', file_init) loader_init = ptr.MarkdownTableFileLoader(file_init) for table_data_init in loader_init.load(): table_merge = pd.DataFrame(table_data_init.as_dataframe()) -# Loading of the device files into a table logger.info('Loading device files') for filename in os.listdir(): f = os.path.join(filename) @@ -32,7 +30,6 @@ except: logger.exception('Error with file: %s', f) -# Load the app compatible devices file logger.info('Loading app compatible devices file: %s', http_file_app) r = requests.get(http_file_app) with open(file_app,'wb') as f: @@ -42,30 +39,27 @@ for table_data_app in loader_app.load(): table_app = pd.DataFrame(table_data_app.as_dataframe()) -# Transpose the table and adapt indexes logger.info('Transposing table and adapting indexes') table_merge = table_merge.set_index('Model Id').transpose() table_merge = table_merge.reset_index() table_merge = table_merge.rename(columns={'index':'Model_Id'}) -# Add the app compatible devices to the table +logger.info('sorting table') +table_merge.sort_values(by=['Model_Id'], inplace=True, key=lambda col: col.str.lower()) + logger.info('Adding app compatible devices to the table') table_merge = table_merge.merge(table_app, how='left',left_on='Model_Id', right_on='Model_Id') -# Add link to the file from the model Id logger.info('Adding links to the file from the model Id') for ind in table_merge.index: table_merge['Model_Id'][ind] = "" + table_merge['Model_Id'][ind] + "" -# Drop unnecessary columns for the table -logger.info('Dropping unnecessary columns and sorting the table') +logger.info('Dropping unnecessary columns') table_merge.drop(columns=['Communication','Frequency','Encrypted','Filename','Power source'], inplace=True) -table_merge.sort_values(by=['Brand'], inplace=True, key=lambda col: col.str.lower()) logger.info('Converting table to HTML') html_table = table_merge.to_html(table_id='devices', escape=False, border=0) -# Read the template file logger.info('Reading template file') with open('devices_template.html', 'r') as f: template = f.read()