def aggregate_final(self, data_dir): """Compiles subject aggregation files""" rows = [] for device in util.list_subdir(data_dir): row = OrderedDict({'device': device}) device_dir = os.path.join(data_dir, device) for subject in util.list_subdir(device_dir): row.update({'subject': subject}) subject_dir = os.path.join(device_dir, subject) if os.path.isdir(os.path.join(subject_dir, 'monsoon')): temp_row = row.copy() row.update( self.get_aggregated_runs_subject( os.path.join(subject_dir, 'monsoon'))) self.add_rows(row, temp_row, rows, subject_dir) else: for browser in util.list_subdir(subject_dir): row.update({'browser': browser}) browser_dir = os.path.join(subject_dir, browser) if os.path.isdir(os.path.join(browser_dir, 'monsoon')): temp_row = row.copy() row.update( self.get_aggregated_runs_subject( os.path.join(browser_dir, 'monsoon'))) self.add_rows(row, temp_row, rows, browser_dir) return rows
def test_list_subdir(self, fixture_dir): test_dir = op.join(fixture_dir, 'test_dir_struct') result_subdirs = util.list_subdir(test_dir) assert len(result_subdirs) == 2 assert 'data_native' in result_subdirs assert 'data_web' in result_subdirs
def aggregate_final(self, data_dir): rows = [] for device in util.list_subdir(data_dir): row = OrderedDict({'device': device}) device_dir = os.path.join(data_dir, device) for subject in util.list_subdir(device_dir): row.update({'subject': subject}) subject_dir = os.path.join(device_dir, subject) if os.path.isdir(os.path.join(subject_dir, 'trepn')): row.update(self.aggregate_trepn_final(os.path.join(subject_dir, 'trepn'))) rows.append(row.copy()) else: for browser in util.list_subdir(subject_dir): row.update({'browser': browser}) browser_dir = os.path.join(subject_dir, browser) if os.path.isdir(os.path.join(browser_dir, 'trepn')): row.update(self.aggregate_trepn_final(os.path.join(browser_dir, 'trepn'))) rows.append(row.copy()) return rows