def print_gradebook(browser, show_validation, hide_homeroom): nav = tertiary_navigation(browser) if nav: print format_table([nav]) rows = [] rows.extend(table_header(browser)) for row in table_rows(browser, show_validation, hide_homeroom): rows.append(row) print format_table(rows, header_rows=2)
def print_table(table): rows = [] row = [] for th in table.query_all.css('thead tr th'): row.append(th.text) rows.append(row) for tr in table.query_all.css('tbody tr'): row = [] for td in tr.query_all.tag('td'): row.append(td.text) rows.append(row) print format_table(rows, header_rows=1)
def printGradebook(contents): contents = contents.replace('<br />', ' ') tabs_table_rows = [] tabs_table_rows.append(worksheet_tabs(contents)) grades_table_rows = [] gradebook_rows = queryHTML('//table[@class="schooltool_gradebook"][2]//tr', contents) for row_number, row in enumerate(gradebook_rows): # we don't care about these rows # first (0): activity description # third (2): 'Apply a grade for all students' if row_number == 1: grades_table_rows.append(gradebook_header(row)) if row_number > 2: columns = [] cells = [cell for cell in queryHTML('//tr/td', row)] for cell in cells: # Student's name text = queryHTML('//td/a[1]/text()', cell) if not text: # Activity inputs text_input_value = queryHTML( '//td//input[@type="text"]/@value', cell) if text_input_value: text = [ "[%s]" % str(text_input_value[0]).ljust(5, '_') ] if not text: # Total and Ave. text = queryHTML('//td/b/text()', cell) if text: text = [text[0].strip()] if not text: # Linked column activities text = queryHTML('//td/span/text()', cell) if text: text = [text[0].strip()] if not text: text = [''] columns.append(text[0].strip().encode('utf-8')) grades_table_rows.append(columns) print format_table(tabs_table_rows) print format_table(grades_table_rows, header_rows=1)
def format(self): dim1 = max([key[0] for key in self.table.keys()]) + 1 dim2 = max([key[1] for key in self.table.keys()]) + 1 table = [] for x in range(dim1): l = [] for y in range(dim2): l.append(self.table.get((x, y), Cell("", None)).data) table.append(l) return format_table(table)