# Path: hecatoncheir/DbProfilerFormatter.py
# def format_non_null_ratio(rows, nulls):
# def format_cardinality(rows, cardinality, nulls):
# def format_data_type(d1, d2):
# def format_value_freq_ratio(rows, nulls, freq):
# def get_validation_rule(column_name, rule, invalid):
# def filter_markdown2html(text):
# def filter_term2popover(html, pos, term, content, orig=None):
# def create_popover_content(term):
# def filter_glossaryterms(html, glossary_terms):
# def format_comment_tooltip(msg, maxlen=20):
# def get_default_template_path():
# def format_number(value):
# def format_minmax(minval, maxval):
# def is_column_unique(most_freq_vals):
# def format_fks(dbname, fks):
# def format_freq_values(freq_vals, row_count, nulls):
# def format_validation_item(val):
# def format_validation_items(vals):
# def filter_plain2html(s):
# def format_table_datamapping(datamapping):
# def format_column_datamapping(datamapping, column_name):
# def format_column_metadata(colmeta, tabmeta, row_count, glossary_terms,
#                            datamapping):
# def format_table_metadata(tabmeta, glossary_terms, datamapping=None):
# def to_table_html(tabdata, validation_rules=None, datamapping=None,
#                   files=None,
#                   glossary_terms=None, template_file=None, editable=False):
# def format_timestamp(ts):
# def get_template_from_file(filename, encoding='utf-8'):
# def to_index_html(data, reponame, schemas=None, tags=None,
#                   show_validation='none', comment=None,
#                   files=None, glossary_terms=None,
#                   template_file=None, editable=False, max_panels=99):
# def to_glossary_html(glossary_terms=None, template_file=None, editable=False):
# 
# Path: hecatoncheir/exception.py
# class DbProfilerException(Exception):
#     source = None
# 
#     def __init__(self, value, source=None):
#         self.value = value
#         self.source = source
# 
#     def __str__(self):
#         return self.value
# 
# class InternalError(Exception):
#     source = None
#     query = None
# 
#     def __init__(self, value, query=None, source=None):
#         self.value = value
#         self.query = query
#         self.source = source
# 
#     def __str__(self):
#         return self.value


import json
import os
import re
import sys
import unittest
from hecatoncheir import DbProfilerFormatter
from hecatoncheir.exception import DbProfilerException, InternalError
        self.assertIsNotNone(re.search('#c1_comment.* data-toggle="tooltip" data-html="true" data-placement="top" title=" this is column comment on c1 with Term2. ">', html))
        # glossary markup in column comment.
        self.assertIsNotNone(re.search(u'<a tabindex="0" data-toggle="popover" data-trigger="focus" data-html="true" title="Term2" data-content="short description of Term2 for c1<br/><div align=right><a href=\'glossary.html#Term2\' target=\'_glossary\'>Details...</a></div>" class="glossary-term">Term2</a>', html))

        # table comment with attached file
        self.assertIsNotNone(re.search('this is table comment.', html))
        self.assertIsNotNone(re.search(u'Attached files:', html))
        self.assertIsNotNone(re.search(u'<a href="attachments/aaa.txt">aaa.txt</a></li>', html))
        # glossary markup in table comment.
        self.assertIsNotNone(re.search(u'<a tabindex="0" data-toggle="popover" data-trigger="focus" data-html="true" title="Term1" data-content="short description of Term1<br/><div align=right><a href=\'glossary.html#Term1\' target=\'_glossary\'>Details...</a></div>" class="glossary-term">Term1</a>', html))

        # foreign keys
        self.assertIsNotNone(re.search(u'orcl\.public\.t2\.html#c2.*Being refered from c2 on public.t2', html))
        self.assertIsNotNone(re.search(u'orcl\.public\.t3\.html#c1.*Refering c1 on public.t3 \(guess\)', html))


    def test_to_table_html_002(self):
        data = """
  {
    "columns": [
      {
        "cardinality": 199999,
        "column_name": "c1",
        "data_type": [
          "NUMBER",
          "22"
        ],
        "max": "200000",
        "min": "1",
        "nulls": 0,

# Path: hecatoncheir/DbProfilerFormatter.py
# def format_non_null_ratio(rows, nulls):
# def format_cardinality(rows, cardinality, nulls):
# def format_data_type(d1, d2):
# def format_value_freq_ratio(rows, nulls, freq):
# def get_validation_rule(column_name, rule, invalid):
# def filter_markdown2html(text):
# def filter_term2popover(html, pos, term, content, orig=None):
# def create_popover_content(term):
# def filter_glossaryterms(html, glossary_terms):
# def format_comment_tooltip(msg, maxlen=20):
# def get_default_template_path():
# def format_number(value):
# def format_minmax(minval, maxval):
# def is_column_unique(most_freq_vals):
# def format_fks(dbname, fks):
# def format_freq_values(freq_vals, row_count, nulls):
# def format_validation_item(val):
# def format_validation_items(vals):
# def filter_plain2html(s):
# def format_table_datamapping(datamapping):
# def format_column_datamapping(datamapping, column_name):
# def format_column_metadata(colmeta, tabmeta, row_count, glossary_terms,
#                            datamapping):
# def format_table_metadata(tabmeta, glossary_terms, datamapping=None):
# def to_table_html(tabdata, validation_rules=None, datamapping=None,
#                   files=None,
#                   glossary_terms=None, template_file=None, editable=False):
# def format_timestamp(ts):
# def get_template_from_file(filename, encoding='utf-8'):
# def to_index_html(data, reponame, schemas=None, tags=None,
#                   show_validation='none', comment=None,
#                   files=None, glossary_terms=None,
#                   template_file=None, editable=False, max_panels=99):
# def to_glossary_html(glossary_terms=None, template_file=None, editable=False):
# 
# Path: hecatoncheir/exception.py
# class DbProfilerException(Exception):
#     source = None
# 
#     def __init__(self, value, source=None):
#         self.value = value
#         self.source = source
# 
#     def __str__(self):
#         return self.value
# 
# class InternalError(Exception):
#     source = None
#     query = None
# 
#     def __init__(self, value, query=None, source=None):
#         self.value = value
#         self.query = query
#         self.source = source
# 
#     def __str__(self):
#         return self.value


# Path: tests/testDbProfilerFormatter.py
import json
import os
import re
import sys
import unittest
from hecatoncheir import DbProfilerFormatter
from hecatoncheir.exception import DbProfilerException, InternalError

        self.assertIsNotNone(re.search('#c1_comment.* data-toggle="tooltip" data-html="true" data-placement="top" title=" this is column comment on c1 with Term2. ">', html))
        # glossary markup in column comment.
        self.assertIsNotNone(re.search(u'<a tabindex="0" data-toggle="popover" data-trigger="focus" data-html="true" title="Term2" data-content="short description of Term2 for c1<br/><div align=right><a href=\'glossary.html#Term2\' target=\'_glossary\'>Details...</a></div>" class="glossary-term">Term2</a>', html))

        # table comment with attached file
        self.assertIsNotNone(re.search('this is table comment.', html))
        self.assertIsNotNone(re.search(u'Attached files:', html))
        self.assertIsNotNone(re.search(u'<a href="attachments/aaa.txt">aaa.txt</a></li>', html))
        # glossary markup in table comment.
        self.assertIsNotNone(re.search(u'<a tabindex="0" data-toggle="popover" data-trigger="focus" data-html="true" title="Term1" data-content="short description of Term1<br/><div align=right><a href=\'glossary.html#Term1\' target=\'_glossary\'>Details...</a></div>" class="glossary-term">Term1</a>', html))

        # foreign keys
        self.assertIsNotNone(re.search(u'orcl\.public\.t2\.html#c2.*Being refered from c2 on public.t2', html))
        self.assertIsNotNone(re.search(u'orcl\.public\.t3\.html#c1.*Refering c1 on public.t3 \(guess\)', html))


    def test_to_table_html_002(self):
        data = """
  {
    "columns": [
      {
        "cardinality": 199999,
        "column_name": "c1",
        "data_type": [
          "NUMBER",
          "22"
        ],
        "max": "200000",
        "min": "1",
        "nulls": 0,

        "validation": {}