Skip to main content

Small utility to ensure files end with one newline.

Project description

End of file

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. It needs python to run but because it's only purpose is to ensure file ends with exactly one new line at the end it can be used to format any type of programming languages or text files.

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

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

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.1.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

end_of_file-1.0.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: end-of-file-1.0.1.tar.gz
  • Upload date:
  • Size: 5.0 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.1.tar.gz
Algorithm Hash digest
SHA256 2706dbc22216ff0ae1ea66d3d9daa3bd7d6c2f52ce8e144b960636d8097cbf7a
MD5 00a67febb3be80f2dc7fd366fa5b7af2
BLAKE2b-256 7246113e9cf2eb0a0d9fcd4f888aca1d53ce39c156f6be2b035c06c81a704b9e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: end_of_file-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 726c473dcc496d6332fa5cda0e04586e1548fc371f14987fef4115eb63ce930e
MD5 00a0d468fb5821bec03f759097c37b8c
BLAKE2b-256 a12c2903eb854178219144e9207fdfe4d5adb4e6318d14471d21190bb239c2d2

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