diff --git a/.travis.yml b/.travis.yml index ee52272..a4e6a58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ sudo: false python: - "3.6" - "3.7" + - "3.8" install: - pip install flake8 - pip install coveralls diff --git a/README.md b/README.md index 859f4b8..cc32b22 100644 --- a/README.md +++ b/README.md @@ -16,3 +16,5 @@ pip install greek-normalisation ## Documentation / Tests See `tests.rst` for usage examples. + +Also, two command-line utilities `toNFC` and `toNFD` are installed which can be used to do unicode normalisation on files (e.g. `toNFC source.txt > nfc_version.txt`). diff --git a/greek_normalisation/convert_files.py b/greek_normalisation/convert_files.py new file mode 100755 index 0000000..1b0d525 --- /dev/null +++ b/greek_normalisation/convert_files.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +import fileinput +import sys + +from .utils import nfc, nfd + + +def convert(func): + lines_changed = 0 + + with fileinput.input() as f: + for line in f: + text = func(line) + print(text, end="") + if text != line: + lines_changed += 1 + + print(f"{lines_changed} lines changed", file=sys.stderr) + + +def to_nfc(): + convert(nfc) + + +def to_nfd(): + convert(nfd) diff --git a/setup.py b/setup.py index dd88d79..ed7441c 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name="greek-normalisation", - version="0.2.1", + version="0.3", description="Python 3 utilities for validating and normalising Ancient Greek text", url="http://github.com/jtauber/greek-normalisation", author="James Tauber", @@ -16,12 +16,19 @@ long_description_content_type="text/markdown", license="MIT", packages=["greek_normalisation"], + entry_points={ + "console_scripts": [ + "toNFC = greek_normalisation.convert_files:to_nfc", + "toNFD = greek_normalisation.convert_files:to_nfd", + ], + }, zip_safe=False, classifiers=[ "Development Status :: 4 - Beta", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", "Topic :: Text Processing :: Linguistic", ], )