Skip to main content

Simple package that generates UTF-8 tables

Project description

utf-table-generator

Модуль генерирует код для печати вот так таких таблиц:

╔════════╦═════════════╦═══════╦═════════╦════╗
║ number ║       float ║     t ║ boolean ║  a ║
╠════════╬═════════════╬═══════╬═════════╬════╣
║    123 ║   12345.456 ║  test ║    True ║  1 ║
╚════════╩═════════════╩═══════╩═════════╩════╝

Вот так использовать:

titles = ('number', 'float', 't', 'boolean', 'a')
variables = (123, 12345.4564876435, 'test', True, 1)
t = Table(titles, variables, precision=3)  # precision -- количество знаков после запятой, по умолчанию 5
print(t.get_code())

Пример сгенерированного кода:

print("╔" + "═" * 8 + "╦" + "═" * 13 + "╦" + "═" * 7 + "╦" + "═" * 9 + "╦" + "═" * 4 + "╗")
print("║%7s%12s%6s%8s%3s ║" % ("number", "float", "t", "boolean", "a"))
print("╠" + "═" * 8 + "╬" + "═" * 13 + "╬" + "═" * 7 + "╬" + "═" * 9 + "╬" + "═" * 4 + "╣")
print("║%7d%12.3f%6s%8s%3d ║" % ())
print("╚" + "═" * 8 + "╩" + "═" * 13 + "╩" + "═" * 7 + "╩" + "═" * 9 + "╩" + "═" * 4 + "╝")

Принимаемые значения: int, float, boolean и все объекты с методом __str__

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

utf_table_generator-1.0.1.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

utf_table_generator-1.0.1-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page