Skip to content

Commit

Permalink
make to2019 a console script entry point
Browse files Browse the repository at this point in the history
  • Loading branch information
jtauber committed Mar 4, 2020
1 parent 7c2db17 commit 2a8ac5e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ pip install greek-normalisation

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`).
Also, three command-line utilities `to2019`, `toNFC` and `toNFD` are installed which can be used to convert U+02BC and U+1FBF to U+2019 and do unicode normalisation on files (e.g. `toNFC source.txt > nfc_version.txt`).
6 changes: 5 additions & 1 deletion greek_normalisation/convert_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import fileinput
import sys

from .utils import nfc, nfd
from .utils import nfc, nfd, convert_to_2019


def convert(func):
Expand All @@ -25,3 +25,7 @@ def to_nfc():

def to_nfd():
convert(nfd)


def to_2019():
convert(convert_to_2019)
23 changes: 0 additions & 23 deletions greek_normalisation/to2019.py

This file was deleted.

4 changes: 4 additions & 0 deletions greek_normalisation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def nfkc(s):
return unicodedata.normalize("NFKC", s)


def convert_to_2019(s):
return s.replace("\u02BC", "\u2019").replace("\u1FBF", "\u2019")


def strip_accents(s):
return nfc("".join(
cp for cp in nfd(s) if cp not in ACCENTS
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name="greek-normalisation",
version="0.3",
version="0.4",
description="Python 3 utilities for validating and normalising Ancient Greek text",
url="http://github.com/jtauber/greek-normalisation",
author="James Tauber",
Expand All @@ -18,6 +18,7 @@
packages=["greek_normalisation"],
entry_points={
"console_scripts": [
"to2019 = greek_normalisation.convert_files:to_2019",
"toNFC = greek_normalisation.convert_files:to_nfc",
"toNFD = greek_normalisation.convert_files:to_nfd",
],
Expand Down

0 comments on commit 2a8ac5e

Please sign in to comment.