def desc(self, table_name): self.check_key_length(table_name) table = Table(PrecompileCommon.SYS_TABLE, PrecompileCommon.USER_TABLE_PREFIX + table_name, "") condition = table.get_condition() user_table = self.select(table, condition) if common.check_result(user_table) is False: return if user_table is not None: user_table_list = list(user_table) if user_table_list is None: return None if len(user_table_list) < 1: return None user_table_obj = json.loads(user_table_list[0]) if user_table_obj is None: return None if len(user_table_obj) < 1: return None if "key_field" not in user_table_obj[0].keys(): return None key_field = user_table_obj[0]["key_field"] value_field = user_table_obj[0]["value_field"] print("INFO >> table {}".format(table_name)) print(" >> key_field: {}".format(key_field)) print(" >> value_field: {}".format(value_field)) return Table(table_name, key_field, value_field) else: raise PrecompileError( "The table {} doesn't exits!".format(table_name))
def print_permission_info(result): """ print permission info """ i = 0 if result is None: return if common.check_result(result) is False: return result_list = list(result) if result_list is None or len(result_list) < 1: return for permission_info in result_list: permission_item = json.loads(permission_info) for permission_obj in permission_item: print("----->> ITEM {}".format(i)) i = i + 1 if "address" in permission_obj.keys(): print(" = address: {}".format( permission_obj["address"])) print(" = enable_num: {}".format( permission_obj["enable_num"])) if i == 0: common.print_info(" ", "Empty Set, permission info: {}".format(result))
def print_cns_info(cns_info): """ print cns information """ if common.check_result(cns_info) is False: return for cns_item in cns_info: cns_obj = json.loads(cns_item) i = 0 for cns in cns_obj: print("CNS ITEM {} >>".format(i)) print("\tContractName: {}".format(cns["name"])) print("\tContractVersion: {}".format(cns["version"])) print("\tContractAddress: {}".format(cns["address"])) i = i + 1 if i == 0: common.print_info(" ", "Empty Set, result: {}".format(cns_info))