Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 Max Taggart
#
# SPDX-License-Identifier: MIT

dev/
*.pyc
*.ipynb
Expand Down
19 changes: 19 additions & 0 deletions LICENSES/MIT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
MIT License Copyright (c) <year> <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<!--
SPDX-FileCopyrightText: 2019 Max Taggart

SPDX-License-Identifier: MIT
-->

# Columnar

A library for creating columnar output strings using data as input.
Expand All @@ -21,7 +27,7 @@ data = [

patterns = [
('Saturday.+', lambda text: style(text, fg='white', bg='blue')),
('\d+km', lambda text: style(text, fg='cyan')),
(r'\d+km', lambda text: style(text, fg='cyan')),
('Omloop Het Nieuwsblad', lambda text: style(text, fg='green')),
('Strade Bianche', lambda text: style(text, fg='white')),
('Milan-San Remo', lambda text: style(text, fg='red')),
Expand Down
6 changes: 6 additions & 0 deletions algorithm.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
<!--
SPDX-FileCopyrightText: 2019 Max Taggart

SPDX-License-Identifier: MIT
-->

if the columns do not all fit, calculate the amount that you would need to subtract from the largest column to make the table fit. if this number is less than 2 times the column delimeter, or is smaller than the next widest column, then distribute the amount between the two largest columns, if this makes them less than 3 times the column delimiter or less than the third largest column, distribute the amount between the four largest columns, etc. The end condition is reached when distributing the reduction between columns leads to a table that will fit in the terminal, or the table collapses down to be less than ncolumns + 1 wide, meaning that it would then contain only column delimiters.
Ideally when a suitable table size is found, the columns would be sized to utiltize the whole width of the screen.
4 changes: 4 additions & 0 deletions columnar/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 Max Taggart
#
# SPDX-License-Identifier: MIT

from .columnar import Columnar

columnar = Columnar()
4 changes: 4 additions & 0 deletions columnar/columnar.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 Max Taggart
#
# SPDX-License-Identifier: MIT

import shutil
import re
import io
Expand Down
4 changes: 4 additions & 0 deletions columnar/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# SPDX-FileCopyrightText: 2019 Max Taggart
#
# SPDX-License-Identifier: MIT

class TableOverflowError(Exception):
pass
3 changes: 3 additions & 0 deletions columnar/images/emojis_and_wide_chars.png.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2019 Max Taggart

SPDX-License-Identifier: MIT
3 changes: 3 additions & 0 deletions columnar/images/example_no_borders.png.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2019 Max Taggart

SPDX-License-Identifier: MIT
3 changes: 3 additions & 0 deletions columnar/images/example_spring_classics.png.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2019 Max Taggart

SPDX-License-Identifier: MIT
4 changes: 4 additions & 0 deletions columnar/test/colors_justifications_headers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 Max Taggart
#
# SPDX-License-Identifier: MIT

from columnar import columnar
from click import style

Expand Down
4 changes: 4 additions & 0 deletions columnar/test/drop_dash_and_none_columns.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 Max Taggart
#
# SPDX-License-Identifier: MIT

from columnar import columnar
from click import style

Expand Down
4 changes: 4 additions & 0 deletions columnar/test/example.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 Max Taggart
#
# SPDX-License-Identifier: MIT

from columnar import columnar

headers = ["User", "Message", "Zip"]
Expand Down
4 changes: 4 additions & 0 deletions columnar/test/lots_of_columns.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 Max Taggart
#
# SPDX-License-Identifier: MIT

from columnar import columnar
from click import style

Expand Down
4 changes: 4 additions & 0 deletions columnar/test/no_borders.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 Max Taggart
#
# SPDX-License-Identifier: MIT

from columnar import columnar
from click import style

Expand Down
4 changes: 4 additions & 0 deletions columnar/test/no_borders_no_headers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 Max Taggart
#
# SPDX-License-Identifier: MIT

from columnar import columnar
from click import style

Expand Down
4 changes: 4 additions & 0 deletions columnar/test/no_headers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 Max Taggart
#
# SPDX-License-Identifier: MIT

from columnar import columnar
from click import style

Expand Down
4 changes: 4 additions & 0 deletions columnar/test/select_columns_two_and_five.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 Max Taggart
#
# SPDX-License-Identifier: MIT

from columnar import columnar
from click import style

Expand Down
4 changes: 4 additions & 0 deletions columnar/test/specify_terminal_width.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 Max Taggart
#
# SPDX-License-Identifier: MIT

from columnar import columnar
from click import style

Expand Down
4 changes: 4 additions & 0 deletions columnar/test/wide_characters_and_emojis.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 Max Taggart
#
# SPDX-License-Identifier: MIT

from columnar import columnar

headers = ['name', 'id', 'host', 'notes']
Expand Down
27 changes: 27 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-FileCopyrightText: 2019 Max Taggart

# SPDX-License-Identifier: MIT

[metadata]
name = Columnar
version = 1.3.1
description = A tool for printing data in a columnar format.
long_description = file:README.md
long_description_content_type = text/markdown
author = Max Taggart
author_email = max.taggart@gmail.com
license = MIT
license_files =
LICENSE.text
LICENSES/*
classifiers =
Programming Language :: Python :: 3.7
License :: OSI Approved :: MIT License
Operating System :: OS Independent

[options]
packages = find:
python_requires = ~= 3.7
install_requires =
toolz
wcwidth
28 changes: 5 additions & 23 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
import setuptools

with open("README.md", "r") as fh:
long_description = fh.read()
# SPDX-FileCopyrightText: 2019 Max Taggart
#
# SPDX-License-Identifier: MIT

setuptools.setup(
name="Columnar",
version="1.3.1",
author="Max Taggart",
author_email="max.taggart@gmail.com",
description="A tool for printing data in a columnar format.",
long_description=long_description,
long_description_content_type="text/markdown",
packages=setuptools.find_packages(),
install_requires=[
'toolz',
'wcwidth',
],
classifiers=[
"Programming Language :: Python :: 3.7",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
)
import setuptools

setuptools.setup()