Skip to main content

Intentionally Blank

Canonicalise the leading indentation of blank lines in text files.

CI Status

Installation

The intentionally-blank package is available on the Python Package Index (PyPI):

https://badge.fury.io/py/intentionally-blank.svg

The package supports Python 3 only. To install:

$ python -m pip install intentionally-blank

Synopsis

For the purposes of this tool, a “blank line” is a line containing only whitespace characters.

Intentionally Blank can apply one or more formatters to a text file for the purposes of modifying the arrangement or representation of whitespace.

To get command-line help, use the --help option:

$ intentionally-blank --help
Usage: intentionally-blank [OPTIONS] COMMAND [ARGS]...

Options:
  --verbosity [CRITICAL|ERROR|WARNING|INFO|DEBUG|NOTSET]
                                  The logging level to use.
  --version                       Show the version and exit.
  --help                          Show this message and exit.

Commands:
  describe-format
  format
  list-formats

To list the available formatters, used the list-formats command:

$ intentionally-blank list-formats
empty
identity
leading
visible

To describe the action of particular formatter, use the describe-format command:

$ intentionally-blank describe-format --format=leading
Blank lines have leading whitespace equal to that on the previous non-blank line.

To actually reformat a text file, we can use the format command. To get help on a particular command, like format, use the command and the --help option:

$ intentionally-blank format --help
Usage: intentionally-blank format [OPTIONS] INPUT OUTPUT

Options:
  --format [empty|identity|leading|visible]
  --help                          Show this message and exit.

Now, use the format command to adjust whitespace:

$ intentionally-blank format --format=leading infile.txt outfile.txt

To have blank lines be completely empty save for the terminating newline sequence, use --format=empty:

$ intentionally-blank format --format=empty infile.txt outfile.txt

Multiple --format options can be provided, and they will be applied in the order given. Here we apply the “leading” format, and then the “visible” format which makes whitespace characters visible:

$ intentionally-blank format --format=leading --format=visible infile.txt outfile.txt

Either the INPUT or OUTPUT positional arguments can be replaced with a hyphen - to cause input to be read from stdin or output to be written to stdout:

$ intentionally-blank format --format=leading --format=visible infile.txt -
"""Model␣for␣aircraft␣flights."""↵
↵
↵
class␣Flight:↵
␣␣␣␣"""A␣flight␣with␣a␣particular␣passenger␣aircraft."""↵
␣␣␣␣↵
␣␣␣␣def␣__init__(self,␣number,␣aircraft):↵
␣␣␣␣␣␣␣␣if␣not␣number[:2].isalpha():↵
␣␣␣␣␣␣␣␣␣␣␣␣raise␣ValueError(f"No␣airline␣code␣in␣'{number}'")↵
␣␣␣␣␣␣␣␣␣␣␣␣↵

MIT License

Copyright (c) 2020 Sixty North AS

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 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.

Metadata

Release files for intentionally-blank 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for intentionally-blank 1.4.0
File Size Uploaded
intentionally-blank-1.4.0.tar.gz 12.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for intentionally-blank 1.4.0
File Interpreter ABI Platform
intentionally_blank-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.3 kB

Release files / intentionally-blank-1.4.0.tar.gz

Download URL intentionally-blank-1.4.0.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f3be2046f28a291bbd03efde46e25081a093bd724507a6b4b0f812b3297951be
BLAKE2b-256 checksum
How to use checksums
02dd18f1ecd32edcf8116be09b2b72f2a56607afce158c6e26fce536ea83ed28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / intentionally_blank-1.4.0-py3-none-any.whl

Download URL intentionally_blank-1.4.0-py3-none-any.whl
Size 17.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4072dfe157ea6603f5cd9d3cc5212d07f1874cfd0e13e555515605199a7f1f0b
BLAKE2b-256 checksum
How to use checksums
8dac73f48ddaae6224ae1ff74e192a1ef4dae83f6531e3bb0c134f17b4a02c76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.3

2 release files

1.1.1

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page