Skip to main content

Small utility to ensure files end with one newline.

Project description

End of file is formatter for dealing with new lines at the end of the files. Eof can remove extra new lines and white spaces, or add missing one if needed. It accepts lists of extensions to look for but can also use own strategy to find text files, hidden files and folders are ignored.

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 and usage

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 --path=./project

To format only specific extensions (case insensitive)

eof --path=./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 --path=./project --check

Strategies

In case extensions flag is not provided eof has two ways of determining if file should be considered.

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.

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

end-of-file-1.0.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

end_of_file-1.0.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file end-of-file-1.0.0.tar.gz.

File metadata

  • Download URL: end-of-file-1.0.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for end-of-file-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9f0a76b915a6b67ca1a61ed9bf9c7398afd7362e3351b167c7d39788ce4f7220
MD5 eeb12112713583d15b6ed61558f428ad
BLAKE2b-256 a144e0d8a4178f50542a8a3c2af515d51ddfb6c70c35b25d1c7d5421b7de25c7

See more details on using hashes here.

File details

Details for the file end_of_file-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: end_of_file-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for end_of_file-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 86e19e4ec4d34ad3908b63a296c587131091f1d4abc7157b090d995cc539304e
MD5 206e72517dd7658947978cae1879595f
BLAKE2b-256 d1a83b0ec13eaca1564d74859983c21b1c073c99537235eaede1ad6fda902f53

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page