diff --git a/.gitignore b/.gitignore index 0819fd4..9525dc9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2019 Max Taggart +# +# SPDX-License-Identifier: MIT + dev/ *.pyc *.ipynb diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt new file mode 100644 index 0000000..204b93d --- /dev/null +++ b/LICENSES/MIT.txt @@ -0,0 +1,19 @@ +MIT License Copyright (c) + +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. diff --git a/README.md b/README.md index 93ad97a..8df7c79 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ + + # Columnar A library for creating columnar output strings using data as input. @@ -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')), diff --git a/algorithm.md b/algorithm.md index 52eebc2..6419655 100644 --- a/algorithm.md +++ b/algorithm.md @@ -1,2 +1,8 @@ + + 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. diff --git a/columnar/__init__.py b/columnar/__init__.py index 85708ae..77f7ca2 100644 --- a/columnar/__init__.py +++ b/columnar/__init__.py @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2019 Max Taggart +# +# SPDX-License-Identifier: MIT + from .columnar import Columnar columnar = Columnar() \ No newline at end of file diff --git a/columnar/columnar.py b/columnar/columnar.py index aeb6d4c..1a12ab8 100644 --- a/columnar/columnar.py +++ b/columnar/columnar.py @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2019 Max Taggart +# +# SPDX-License-Identifier: MIT + import shutil import re import io diff --git a/columnar/exceptions.py b/columnar/exceptions.py index 4266dc3..36edcc1 100644 --- a/columnar/exceptions.py +++ b/columnar/exceptions.py @@ -1,2 +1,6 @@ +# SPDX-FileCopyrightText: 2019 Max Taggart +# +# SPDX-License-Identifier: MIT + class TableOverflowError(Exception): pass \ No newline at end of file diff --git a/columnar/images/emojis_and_wide_chars.png.license b/columnar/images/emojis_and_wide_chars.png.license new file mode 100644 index 0000000..eb3c347 --- /dev/null +++ b/columnar/images/emojis_and_wide_chars.png.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2019 Max Taggart + +SPDX-License-Identifier: MIT diff --git a/columnar/images/example_no_borders.png.license b/columnar/images/example_no_borders.png.license new file mode 100644 index 0000000..eb3c347 --- /dev/null +++ b/columnar/images/example_no_borders.png.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2019 Max Taggart + +SPDX-License-Identifier: MIT diff --git a/columnar/images/example_spring_classics.png.license b/columnar/images/example_spring_classics.png.license new file mode 100644 index 0000000..eb3c347 --- /dev/null +++ b/columnar/images/example_spring_classics.png.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2019 Max Taggart + +SPDX-License-Identifier: MIT diff --git a/columnar/test/colors_justifications_headers.py b/columnar/test/colors_justifications_headers.py index 5fd818b..2b51b7b 100644 --- a/columnar/test/colors_justifications_headers.py +++ b/columnar/test/colors_justifications_headers.py @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2019 Max Taggart +# +# SPDX-License-Identifier: MIT + from columnar import columnar from click import style diff --git a/columnar/test/drop_dash_and_none_columns.py b/columnar/test/drop_dash_and_none_columns.py index 13af5d3..5390b54 100644 --- a/columnar/test/drop_dash_and_none_columns.py +++ b/columnar/test/drop_dash_and_none_columns.py @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2019 Max Taggart +# +# SPDX-License-Identifier: MIT + from columnar import columnar from click import style diff --git a/columnar/test/example.py b/columnar/test/example.py index fb0eda1..366fc6c 100644 --- a/columnar/test/example.py +++ b/columnar/test/example.py @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2019 Max Taggart +# +# SPDX-License-Identifier: MIT + from columnar import columnar headers = ["User", "Message", "Zip"] diff --git a/columnar/test/lots_of_columns.py b/columnar/test/lots_of_columns.py index 5c2406f..8488915 100644 --- a/columnar/test/lots_of_columns.py +++ b/columnar/test/lots_of_columns.py @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2019 Max Taggart +# +# SPDX-License-Identifier: MIT + from columnar import columnar from click import style diff --git a/columnar/test/no_borders.py b/columnar/test/no_borders.py index 58ac1d9..8f898c0 100644 --- a/columnar/test/no_borders.py +++ b/columnar/test/no_borders.py @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2019 Max Taggart +# +# SPDX-License-Identifier: MIT + from columnar import columnar from click import style diff --git a/columnar/test/no_borders_no_headers.py b/columnar/test/no_borders_no_headers.py index 71a21ab..7179129 100644 --- a/columnar/test/no_borders_no_headers.py +++ b/columnar/test/no_borders_no_headers.py @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2019 Max Taggart +# +# SPDX-License-Identifier: MIT + from columnar import columnar from click import style diff --git a/columnar/test/no_headers.py b/columnar/test/no_headers.py index 28f7266..cd311d8 100644 --- a/columnar/test/no_headers.py +++ b/columnar/test/no_headers.py @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2019 Max Taggart +# +# SPDX-License-Identifier: MIT + from columnar import columnar from click import style diff --git a/columnar/test/select_columns_two_and_five.py b/columnar/test/select_columns_two_and_five.py index 454cbbe..5a0e2ac 100644 --- a/columnar/test/select_columns_two_and_five.py +++ b/columnar/test/select_columns_two_and_five.py @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2019 Max Taggart +# +# SPDX-License-Identifier: MIT + from columnar import columnar from click import style diff --git a/columnar/test/specify_terminal_width.py b/columnar/test/specify_terminal_width.py index 0b24344..a205fd5 100644 --- a/columnar/test/specify_terminal_width.py +++ b/columnar/test/specify_terminal_width.py @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2019 Max Taggart +# +# SPDX-License-Identifier: MIT + from columnar import columnar from click import style diff --git a/columnar/test/wide_characters_and_emojis.py b/columnar/test/wide_characters_and_emojis.py index a322356..68f55dd 100644 --- a/columnar/test/wide_characters_and_emojis.py +++ b/columnar/test/wide_characters_and_emojis.py @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2019 Max Taggart +# +# SPDX-License-Identifier: MIT + from columnar import columnar headers = ['name', 'id', 'host', 'notes'] diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..ff409b8 --- /dev/null +++ b/setup.cfg @@ -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 diff --git a/setup.py b/setup.py index 3bf6e6d..721939a 100644 --- a/setup.py +++ b/setup.py @@ -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()