Пример #1
0
def get_table(items):
    table = GridspecLayout(len(items), 2)
    fmt_mapping = get_fmt_mapping()
    for row_id, item in enumerate(items):
        name = item["name"]
        formatter = fmt_mapping[item["fmt"]]
        value = formatter(item["value"])
        if "alert" in item and item["alert"]:
            name = fmt_color(name, "var(--jp-error-color1)")
            value = fmt_color(value, "var(--jp-error-color1)")

        table[row_id, 0] = widgets.HTML(name)
        table[row_id, 1] = widgets.HTML(value)

    return VBox([table])
Пример #2
0
import jinja2
from jinja2 import Environment, PackageLoader

from pandas_profiling.config import config
from pandas_profiling.report.formatters import get_fmt_mapping

# Initializing Jinja
from pandas_profiling.utils.paths import get_html_template_path

package_loader = PackageLoader("pandas_profiling",
                               "report/presentation/flavours/html/templates")
jinja2_env = Environment(lstrip_blocks=True,
                         trim_blocks=True,
                         loader=package_loader)
fmt_mapping = get_fmt_mapping()
for key, value in fmt_mapping.items():
    jinja2_env.filters[key] = value

jinja2_env.filters["fmt_badge"] = lambda x: re.sub(
    r"\((\d+)\)", r'<span class="badge">\1</span>', x)
jinja2_env.filters["dynamic_filter"] = lambda x, v: fmt_mapping[v](x)


def template(template_name: str) -> jinja2.Template:
    """Get the template object given the name.

    Args:
      template_name: The name of the template file (.html)

    Returns: