From e489e7de9954e40a15466b92431fff54c35e93c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Tue, 21 Jul 2020 14:48:47 +0100 Subject: [PATCH 1/4] Add SPDX headers to the files in the repository. This makes the code follow the REUSE.software specifications, which allow safe and low-friction reuse of code. --- .gitignore | 4 ++++ LICENSES/MIT.txt | 19 +++++++++++++++++++ README.md | 6 ++++++ algorithm.md | 6 ++++++ columnar/__init__.py | 4 ++++ columnar/columnar.py | 4 ++++ columnar/exceptions.py | 4 ++++ .../images/emojis_and_wide_chars.png.license | 3 +++ .../images/example_no_borders.png.license | 3 +++ .../example_spring_classics.png.license | 3 +++ .../test/colors_justifications_headers.py | 4 ++++ columnar/test/drop_dash_and_none_columns.py | 4 ++++ columnar/test/example.py | 4 ++++ columnar/test/lots_of_columns.py | 4 ++++ columnar/test/no_borders.py | 4 ++++ columnar/test/no_borders_no_headers.py | 4 ++++ columnar/test/no_headers.py | 4 ++++ columnar/test/select_columns_two_and_five.py | 4 ++++ columnar/test/specify_terminal_width.py | 4 ++++ columnar/test/wide_characters_and_emojis.py | 4 ++++ setup.py | 4 ++++ 21 files changed, 100 insertions(+) create mode 100644 LICENSES/MIT.txt create mode 100644 columnar/images/emojis_and_wide_chars.png.license create mode 100644 columnar/images/example_no_borders.png.license create mode 100644 columnar/images/example_spring_classics.png.license 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..90173fb 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ + + # Columnar A library for creating columnar output strings using data as input. 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.py b/setup.py index 3bf6e6d..87830ca 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2019 Max Taggart +# +# SPDX-License-Identifier: MIT + import setuptools with open("README.md", "r") as fh: From 60da5e717b1c1a7ce2763054396c99ad661fa461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Tue, 21 Jul 2020 14:52:50 +0100 Subject: [PATCH 2/4] Migrate wheel setup to declarative style. This pretty covers the whole content of the previous setup.py file, but as a declarative file, that does not require to execute code to run. --- setup.cfg | 25 +++++++++++++++++++++++++ setup.py | 24 +----------------------- 2 files changed, 26 insertions(+), 23 deletions(-) create mode 100644 setup.cfg diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..829e88f --- /dev/null +++ b/setup.cfg @@ -0,0 +1,25 @@ +# 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_files = + LICENSE.text + LICENSES/* +classifiers = + Programming Language :: Python :: 3.7 + License :: OSI Approved :: MIT License + Operating System :: OS Independent + +[options] +packages = find: +install_requires = + toolz + wcwidth diff --git a/setup.py b/setup.py index 87830ca..721939a 100644 --- a/setup.py +++ b/setup.py @@ -4,26 +4,4 @@ import setuptools -with open("README.md", "r") as fh: - long_description = fh.read() - -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", - ], -) - +setuptools.setup() From db560e6c97ae9e9984ce8866f29bd51404e6e534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Tue, 21 Jul 2020 14:55:01 +0100 Subject: [PATCH 3/4] Repeat classifiers as structured metadata. While the classifiers already included the supported Python version and the license, they are not actually built into the wheel. Add an explicit license metadata and a python_requires option. --- setup.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.cfg b/setup.cfg index 829e88f..ff409b8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,6 +10,7 @@ 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/* @@ -20,6 +21,7 @@ classifiers = [options] packages = find: +python_requires = ~= 3.7 install_requires = toolz wcwidth From e739e8a7ebb3c59bc001b7484f8e4d841af54858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Wed, 22 Jul 2020 11:27:22 +0100 Subject: [PATCH 4/4] Add missing raw-string prefix on the example. This just makes it pass flake8 if used identically in tests. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 90173fb..8df7c79 100644 --- a/README.md +++ b/README.md @@ -27,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')),