File: _dict.py

package info (click to toggle)
freeorion 0.5.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 194,920 kB
  • sloc: cpp: 186,821; python: 40,979; ansic: 1,164; xml: 721; makefile: 32; sh: 7
file content (13 lines) | stat: -rw-r--r-- 383 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
from collections.abc import Mapping
from typing import Any

from common.print_utils._fields import Text
from common.print_utils._table import Table


def dict_to_table(data: Mapping[str, Any], name=None) -> Table:
    t = Table(Text("Key"), Text("Value", align=">"), hide_header=True, table_name=name)

    for key, val in data.items():
        t.add_row(key, str(val))
    return t