kuromon
Convert a list of dict, dataclass, Pydantic or POPO objects into a string represented table.
Requirements
- Python 3.7+
Installation
pip install kuromon
# or if you want to use Pydantic along with kuromon
pip install kuromon[pydantic]
Usage
from kuromon import to_table
dict_data = [
{"id": 1, "name": "foo", "tags": None},
{"id": 2, "name": "bar", "tags": ["a"]},
]
print(to_table(dict_data))
# | | id | name | tags |
# |----|------|--------|--------|
# | 0 | 1 | foo | |
# | 1 | 2 | bar | ['a'] |
# Disable indexing by setting index=False
print(to_table(dict_data, index=False))
# | id | name | tags |
# |------|--------|--------|
# | 1 | foo | |
# | 2 | bar | ['a'] |
# Change the table format via tablefmt
# NOTE: You can use the following tabulate formats
# https://github.com/astanin/python-tabulate#table-format
print(to_table(dict_data, tablefmt="plain"))
# 0 1 foo
# 1 2 bar ['a']
The above example uses a list of dict objects. You can also use a list of dataclass or Pydantic objects.
from dataclasses import dataclass
from typing import List, Optional
from dacite import from_dict
from pydantic import BaseModel
from kuromon import to_table
class TestModel(BaseModel):
id: int
name: str
tags: Optional[List[str]]
@dataclass
class TestDataClass:
id: int
name: str
tags: Optional[List[str]]
dict_data = [
{"id": 1, "name": "foo", "tags": None},
{"id": 2, "name": "bar", "tags": ["a"]},
]
pydantic_data = [TestModel.parse_obj(obj) for obj in dict_data]
dataclass_data = [from_dict(data_class=TestDataClass, data=obj) for obj in dict_data]
print(to_table(pydantic_data))
print(to_table(dataclass_data))
Metadata
Release files for kuromon 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kuromon-0.2.0.tar.gz | 3.8 kB | Without provenance | Details for kuromon-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kuromon-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for kuromon-0.2.0-py3-none-any.whl |
Total release size: 7.7 kB
Release files / kuromon-0.2.0.tar.gz
| Download URL | kuromon-0.2.0.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
502f63042acb51e004f06abc07c46b6bd5ee2c113940a4d77eb95b7d467c23a2
|
|
BLAKE2b-256 checksum How to use checksums |
3b68a40e9dbeee3ab0b28ec5e24c9b2179224d7aabdf21636f33cd619a33b8d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.7.6 Darwin/21.5.0
|
Release files / kuromon-0.2.0-py3-none-any.whl
| Download URL | kuromon-0.2.0-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4956c7dc85d665021f531dc70b35f90ebed61f0b8f123308943c9f1447e2650b
|
|
BLAKE2b-256 checksum How to use checksums |
f2eab8f495a3e238b4569f6fd75bcb58afb02650954147757930b3aff8aabd24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.7.6 Darwin/21.5.0
|
Security for kuromon 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.