本文整理汇总了Python中tableprint.table方法的典型用法代码示例。如果您正苦于以下问题:Python tableprint.table方法的具体用法?Python tableprint.table怎么用?Python tableprint.table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tableprint
的用法示例。
在下文中一共展示了tableprint.table方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dispatch
# 需要导入模块: import tableprint [as 别名]
# 或者: from tableprint import table [as 别名]
def dispatch(cls, ns):
logging.debug("File Dispatch entered")
explorer = cls(ns)
explorer.scan()
if ns.catalog['format'] == "ascii_table":
headers = ["Path", "Mime/Type", "pii"]
tableprint.table(explorer.get_tabular(), headers)
elif ns.catalog['format'] == "json":
FileStore.save_schemas(explorer)
示例2: output
# 需要导入模块: import tableprint [as 别名]
# 或者: from tableprint import table [as 别名]
def output(cls, ns, explorer):
if ns.catalog['format'] == "ascii_table":
headers = ["schema", "table", "column", "has_pii"]
tableprint.table(explorer.get_tabular(ns.list_all), headers)
elif ns.catalog['format'] == "json":
FileStore.save_schemas(explorer)
elif ns.catalog['format'] == "db":
DbStore.save_schemas(explorer)
示例3: get_tabular
# 需要导入模块: import tableprint [as 别名]
# 或者: from tableprint import table [as 别名]
def get_tabular(self, list_all):
tabular = []
for schema in self.get_schemas():
for table in schema.get_children():
for column in table.get_children():
if list_all or column.has_pii():
tabular.append([schema.get_name(), table.get_name(),
column.get_name(), column.has_pii()])
return tabular
示例4: _get_query
# 需要导入模块: import tableprint [as 别名]
# 或者: from tableprint import table [as 别名]
def _get_query(self, schema_name, table_name, column_list):
count = self._get_table_count(schema_name, table_name)
logging.debug("No. of rows in {}.{} is {}".format(schema_name, table_name, count))
if count < self.small_table_max:
logging.debug("Choosing a SELECT query as table size is small")
query = self._get_select_query(schema_name, table_name, column_list)
else:
try:
query = self._get_sample_query(schema_name, table_name, column_list)
logging.debug("Choosing a SAMPLE query as table size is big")
except NotImplementedError:
logging.warning("Sample Row is not implemented for %s" % self.__class__.__name__)
query = self._get_select_query(schema_name, table_name, column_list)
return query
示例5: get_columns
# 需要导入模块: import tableprint [as 别名]
# 或者: from tableprint import table [as 别名]
def get_columns(self, schema_name, table_name):
self._load_catalog()
tables = self.get_tables(schema_name)
for t in tables:
if t.get_name() == table_name:
return t.get_children()
raise ValueError("{} table not found".format(table_name))
示例6: test_context
# 需要导入模块: import tableprint [as 别名]
# 或者: from tableprint import table [as 别名]
def test_context():
"""Tests the table context manager"""
output = StringIO()
with TableContext('ABC', style='round', width=5, out=output) as t:
t([1, 2, 3])
t([4, 5, 6])
assert output.getvalue() == '╭───────┬───────┬───────╮\n│ A │ B │ C │\n├───────┼───────┼───────┤\n│ 1 │ 2 │ 3 │\n│ 4 │ 5 │ 6 │\n╰───────┴───────┴───────╯\n' # noqa
示例7: test_table
# 需要导入模块: import tableprint [as 别名]
# 或者: from tableprint import table [as 别名]
def test_table():
"""Tests the table function"""
output = StringIO()
table([[1, 2, 3], [4, 5, 6]], 'ABC', style='round', width=5, out=output)
assert output.getvalue() == '╭───────┬───────┬───────╮\n│ A │ B │ C │\n├───────┼───────┼───────┤\n│ 1 │ 2 │ 3 │\n│ 4 │ 5 │ 6 │\n╰───────┴───────┴───────╯\n' # noqa
output = StringIO()
table(["bar"], "foo", style='grid', width=3, out=output)
assert output.getvalue() == '+---+---+---+\n| f| o| o|\n+---+---+---+\n| b| a| r|\n+---+---+---+\n' # noqa