summaryrefslogtreecommitdiff
path: root/examples/table_creation.py
diff options
context:
space:
mode:
authorxNinjaKittyx <xNinjaKittyx@users.noreply.github.com>2020-12-15 17:21:33 -0800
committerxNinjaKittyx <xNinjaKittyx@users.noreply.github.com>2020-12-15 18:20:13 -0800
commit9aa54a5b27468d61337528cb1e1b5b9b11a80978 (patch)
tree567693115cc101efb9254a96d96d80e9f9ccd557 /examples/table_creation.py
parent03c65c60b39e369958b056c5c844d36d515c8a63 (diff)
downloadcmd2-git-ci_improvements.tar.gz
Adds pre-commit config to run various lintersci_improvements
This ads black, isort, pyupgrade, and flake8 to pre-commit-config.yaml There are also some small changes to travis.yml and tasks.py to reduce some repeated configurations that should be consolidated into setup.cfg. Most other changes are automated by the linter scripts.
Diffstat (limited to 'examples/table_creation.py')
-rwxr-xr-xexamples/table_creation.py38
1 files changed, 20 insertions, 18 deletions
diff --git a/examples/table_creation.py b/examples/table_creation.py
index 6325b200..e199afdc 100755
--- a/examples/table_creation.py
+++ b/examples/table_creation.py
@@ -11,6 +11,7 @@ from cmd2.table_creator import AlternatingTable, BorderedTable, Column, Horizont
class DollarFormatter:
"""Example class to show that any object type can be passed as data to TableCreator and converted to a string"""
+
def __init__(self, val: float) -> None:
self.val = val
@@ -28,27 +29,28 @@ green = functools.partial(ansi.style, fg=ansi.fg.green)
columns: List[Column] = list()
columns.append(Column("Name", width=20))
columns.append(Column("Address", width=38))
-columns.append(Column("Income", width=14,
- header_horiz_align=HorizontalAlignment.RIGHT,
- data_horiz_align=HorizontalAlignment.RIGHT))
+columns.append(
+ Column("Income", width=14, header_horiz_align=HorizontalAlignment.RIGHT, data_horiz_align=HorizontalAlignment.RIGHT)
+)
# Table data which demonstrates handling of wrapping and text styles
data_list: List[List[Any]] = list()
-data_list.append(["Billy Smith",
- "123 Sesame St.\n"
- "Fake Town, USA 33445", DollarFormatter(100333.03)])
-data_list.append(["William Longfellow Marmaduke III",
- "984 Really Long Street Name Which Will Wrap Nicely\n"
- "Apt 22G\n"
- "Pensacola, FL 32501", DollarFormatter(55135.22)])
-data_list.append(["James " + blue("Bluestone"),
- bold_yellow("This address has line feeds,\n"
- "text styles, and wrapping. ") + blue("Style is preserved across lines."),
- DollarFormatter(300876.10)])
-data_list.append(["John Jones",
- "9235 Highway 32\n"
- + green("Greenville") + ", SC 29604",
- DollarFormatter(82987.71)])
+data_list.append(["Billy Smith", "123 Sesame St.\n" "Fake Town, USA 33445", DollarFormatter(100333.03)])
+data_list.append(
+ [
+ "William Longfellow Marmaduke III",
+ "984 Really Long Street Name Which Will Wrap Nicely\n" "Apt 22G\n" "Pensacola, FL 32501",
+ DollarFormatter(55135.22),
+ ]
+)
+data_list.append(
+ [
+ "James " + blue("Bluestone"),
+ bold_yellow("This address has line feeds,\n" "text styles, and wrapping. ") + blue("Style is preserved across lines."),
+ DollarFormatter(300876.10),
+ ]
+)
+data_list.append(["John Jones", "9235 Highway 32\n" + green("Greenville") + ", SC 29604", DollarFormatter(82987.71)])
def ansi_print(text):