Skip to content

Commit

Permalink
Add first version of autonl.
Browse files Browse the repository at this point in the history
  • Loading branch information
yukihira1992 committed Oct 1, 2020
1 parent 06eaddf commit f2aeda3
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
================
autonl CHANGELOG
================


0.1.0 (2020-10-02)
------------------
- Format single file
1 change: 0 additions & 1 deletion README.md

This file was deleted.

21 changes: 21 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
======
autonl
======

autonl automatically formats newline at end of file.


Installation
============

Installing from PyPI::

pip install --upgrade autonl


Usage
=====

Formatting newline at end of file::

autonl <filename>
1 change: 1 addition & 0 deletions autonl/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.1.0'
22 changes: 22 additions & 0 deletions autonl/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import argparse


def main():
parser = argparse.ArgumentParser()
parser.add_argument('filename')

args = parser.parse_args()

_format(args.filename)


def _format(filename):
with open(filename, mode='rb') as fp:
fp.seek(-1, 2)
last_byte = fp.read(1)

if last_byte == b'\n':
return

with open(filename, mode='ab') as fp:
fp.write(b'\n')
2 changes: 2 additions & 0 deletions entry_points.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[console_scripts]
autonl = autonl.cli:main
35 changes: 35 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[metadata]
name = autonl
version = attr: autonl.__version__
description = Manage newline at end of file
long_description = file: README.rst
long_description_content_type = text/x-rst
url = https://github.com/yukihira1992/autonl
author = Takayuki Hirayama
author_email = [email protected]
license = MIT
classifiers =
Development Status :: 1 - Planning
Environment :: Console
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Topic :: Software Development :: Libraries :: Python Modules
Topic :: Software Development :: Quality Assurance
Topic :: Text Processing
Topic :: Text Processing :: Filters
keywords = newline, text, EOF, automation, format

[options]
zip_safe = False
python_requires = >=3.5
packages =
autonl
entry_points = file: entry_points.cfg
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from setuptools import setup

setup()

0 comments on commit f2aeda3

Please sign in to comment.