Skip to main content

End of file

End of file is formatter to ensure text files always end with one newline. Eof is able to resolve every possible situation - missing newline, more then one newline and whitespaces mixed with newlines. Simple configuration is done using parameters, no config file is needed.

Configurable options:

  • include or exclude hidden files (file or folders starting with dot)
  • blacklisted strings that are found inside traversed paths
  • whitelisted extensions
  • whitelisted files that are registered with git
  • identification of text files (mimetype or bruteforce)
  • validation only mode for ci pipelines

The code is short and dead simple so if you have more questions feel free to open an issue or take a look into src.

Installation

End_of_file is python script and thus python3.6 or newer must be present on the system. Eof is just another pip package and can be installed with pip install end-of-file.

Usage

Installation adds Eof to your environment so feel free to try

eof --help

To format project

eof ./project

If you are using git and are concerned only about files that are registered to git following flag can be used. Git must be installed for this option to work.

eof ./project --git

To format only specific extensions

eof ./project --extensions=txt,md,py,rb,cpp

To check in ci/cd if project is formatted correctly, return 0 if yes, 1 if changes are needed. Files are not changed.

eof ./project --check

In case you have for example build destination in your project and want to skip it you can use --ignore flag. Paths with substring from this option are skipped.

eof --ignore /dist -i egg-info

Circleci job example

circleci-job:
  docker:
    - image: circleci/python:3
  steps:
    - checkout
    - run: pip install end-of-file
    - run: eof --check

Strategies

Eof needs to have a way to identify files that should be checked for correct newline. There are two options to choose from.

Bruteforce (default)

Bruteforce strategy just opens the file and tries to read first line, if that does not work it assumes the file does not contain text and is skipped. This should be the most precise but may take more time.

eof --strategy='bruteforce'

Mimetype

Mimetype strategy checks extensions against lookup table.

eof --strategy='mimetype'

Testing

Code is fairly well tested, feel free to take a look.

License

BSD 3-Clause

Metadata

Release files for end-of-file 1.1.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 end-of-file 1.1.0
File Size Uploaded
end-of-file-1.1.0.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for end-of-file 1.1.0
File Interpreter ABI Platform
end_of_file-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.1 kB

Release files / end-of-file-1.1.0.tar.gz

Download URL end-of-file-1.1.0.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f2274efef7f1bf3d57325e16989058a57cf77e04a926d7397d04906cacce52e6
BLAKE2b-256 checksum
How to use checksums
f2e10717e44720f71353957d9b701cad571827f066896d2bda117233ae43af58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

Release files / end_of_file-1.1.0-py3-none-any.whl

Download URL end_of_file-1.1.0-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
30579a7c1560307127f6826a6695d16a5d1f601203a8bfd271707d35b4adff77
BLAKE2b-256 checksum
How to use checksums
17b20d012f198815a2ab95794d386d1f50b36a6eced97c394f0e881657bd2ad4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.1

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