def _render(self, all_revs=0, data=None, filters=None, s=None): """Render return data with a template.""" if data: for item in data: suite_id = SuiteId.from_idx_branch_revision( item["idx"], item["branch"], item["revision"]) item["href"] = suite_id.to_web() item["date"] = str( get_timepoint_from_seconds_since_unix_epoch(item["date"])) tmpl = self.props["template_env"].get_template("prefix-index.html") self.write( tmpl.render( title=self.props["title"], host=self.props["host_name"], rose_version=self.props["rose_version"], script="/static", service_root=self.service_root, prefix=self.prefix, prefix_source_url=self.source_url, known_keys=self.dao.get_known_keys(), query_operators=self.dao.get_query_operators(), all_revs=all_revs, filters=filters, s=s, data=data, ))
def _display_maps(opts, ws_client, dict_rows, url=None): """Display returned suite details.""" report = ws_client.event_handler try: terminal_cols = int(ws_client.popen("stty", "size")[0].split()[1]) except (IndexError, RosePopenError, ValueError): terminal_cols = None if terminal_cols == 0: terminal_cols = None if opts.quietness and not opts.print_format: opts.print_format = PRINT_FORMAT_QUIET elif not opts.print_format: opts.print_format = PRINT_FORMAT_DEFAULT all_keys = ws_client.get_known_keys() for dict_row in dict_rows: suite_id = SuiteId.from_idx_branch_revision(dict_row["idx"], dict_row["branch"], dict_row["revision"]) dict_row["suite"] = suite_id.to_string_with_version() if "%local" in opts.print_format: dict_row["local"] = suite_id.get_status(getattr( opts, "user", None)) all_keys += ["suite"] if "%local" in opts.print_format: all_keys += ["local"] more_keys = [] for key in REC_COL_IN_FORMAT.findall(opts.print_format): if key not in all_keys: more_keys.append(key) all_keys += more_keys if opts.sort is None or opts.sort not in all_keys: opts.sort = "revision" dict_rows.sort(key=lambda x: x[opts.sort]) if opts.reverse: dict_rows.reverse() keylist = [] for key in all_keys: if "%" + key in opts.print_format: keylist.append(key) if not opts.no_headers: dummy_row = {} for key in all_keys: dummy_row[key] = key dict_rows.insert(0, dummy_row) dict_rows = _align(dict_rows, keylist) for dict_row in dict_rows: out = opts.print_format for key, value in dict_row.items(): if "%" + key in out: out = str(out).replace("%" + str(key), str(value), 1) out = str(out.replace("%%", "%").expandtabs().rstrip()) report(SuiteEvent(out.expandtabs() + "\n"), prefix="", clip=terminal_cols) report(SuiteInfo(dict_row), prefix="") if url is not None: report(URLEvent(url + "\n"), prefix="")