def branch(): message = T('支行管理') table_name = 'branch' vars = dict(request.vars) sql = utils.build_sql(bankdb, table_name, vars) table_values, column_name_list, primary_key_list, column_type_list = utils.get_table_info(bankdb, table_name) if sql is not None: try: table_values = bankdb.executesql(sql, as_dict=True) except Exception as e: response.flash = T('操作失败,请检查参数。' + str(e)) if not 'select' in vars: table_values, column_name_list, primary_key_list, column_type_list = utils.get_table_info(bankdb, table_name) operations = ['select', 'insert', 'update', 'delete'] return dict(locals())
def loaninfo(): message = T('贷款状态查询') table_name = 'loaninfo' response.view = 'default/branch.html' vars = dict(request.vars) sql = utils.build_sql(bankdb, table_name, vars) table_values, column_name_list, primary_key_list, column_type_list = utils.get_table_info(bankdb, table_name) if sql is not None: try: table_values = bankdb.executesql(sql, as_dict=True) except Exception as e: response.flash = T('操作失败,请检查参数。' + str(e)) if not 'select' in vars: table_values, column_name_list, primary_key_list, column_type_list = utils.get_table_info(bankdb, table_name) operations = ['select'] return dict(locals())
def print_search_results(results, min_i, max_i): """Prints the formatted results from a search of posts Args: results ([results row]): The list of search result rows min_i (int): The minimum index of the printed results range (inclusive) max_i (int): The maximum index of the printed results range (exclusive) """ # Get table max_widths = {2: 20, 3: 30} # title and body (index 2 and 3) before index header = [ "i", "pid", "pdate", "title", "body", "poster", "# keywords", "votes", "answers" ] table, widths = get_table_info(results[min_i:max_i], header, trunc_widths=max_widths, index_start=min_i + 1) # Start indices at 1 # Generate width string # Right-aligned index, 5 left-aligned columns, 3 right-aligned columns width_str = "{{:>{}}} " + "{{:{}}} " * 5 + "{{:>{}}} " * 2 + "{{:>{}}}" width_str = width_str.format(*widths) # Print the table print_table(table, width_str, widths) print("")
def print_search_results(results, min_i, max_i, answer=False, accepted_id=None): """Prints the formatted results from a search of posts Args: results ([results row]): The list of search result rows min_i (int): The minimum index of the printed results range (inclusive) max_i (int): The maximum index of the printed results range (exclusive) answer(bool): Whether the results are answers or not """ # Get table if answer: max_widths = {0: 80} # body (index 0) before index header = ["Index", "Body", "CreationDate", "Score"] else: max_widths = {1: 30} # title (index 2) before index header = ["Index", "Title", "CreationDate", "Score", "AnswerCount"] table, widths = get_table_info(results[min_i:max_i], header, trunc_widths=max_widths, index_start=min_i + 1, # Start indices at 1 answer=answer) if accepted_id: table[1][0] = "*" + table[1][0] # Generate width string # Right-aligned index * len(header) width_str ="{{:{}}} " * len(header) width_str = width_str.format(*widths) # Print the table print_table(table, width_str, widths) print("")
def print_badges(results, min_i, max_i): """Prints the formatted results from a list of badges Args: results ([badge row]): The list of badge rows min_i (int): The minimum index of the printed results range (inclusive) max_i (int): The maximum index of the printed results range (exclusive) """ # Get table header = ["i", "name", "type"] table, widths = get_table_info(results[min_i:max_i], header, index_start=min_i + 1) # Start indices at 1 # Print the table width_str = "{{:>{}}} {{:{}}} {{:{}}}".format(*widths) print_table(table, width_str, widths) print("")