From 58cd0be0fda19d309d939e30ba2e5db690a9c8a7 Mon Sep 17 00:00:00 2001 From: Stefano Cossu Date: Sun, 21 Aug 2022 15:14:40 -0700 Subject: [PATCH] Rebrand to ScriptShifter. --- Dockerfile | 4 ++-- NOTES.md | 6 +++--- README.md | 6 +++--- doc/config.md | 8 ++++---- doc/hooks.md | 10 +++++----- doc/rest_api.md | 2 +- entrypoint.sh | 4 ++-- {transliterator => scriptshifter}/__init__.py | 0 {transliterator => scriptshifter}/exceptions.py | 0 {transliterator => scriptshifter}/hooks/__init__.py | 0 {transliterator => scriptshifter}/hooks/test.py | 2 +- {transliterator => scriptshifter}/rest_api.py | 4 ++-- .../static/milligram.min.css | 0 .../static/milligram.min.css.map | 0 {transliterator => scriptshifter}/static/normalize.css | 0 {transliterator => scriptshifter}/tables/__init__.py | 4 ++-- .../tables/data/_cyrillic_base.yml | 0 .../tables/data/_ignore_base.yml | 0 .../tables/data/armenian.yml | 0 .../tables/data/asian_cyrillic.yml | 0 .../tables/data/azerbaijani.yml | 0 .../tables/data/belarusian.yml | 0 .../tables/data/bulgarian.yml | 0 .../tables/data/chinese.yml | 0 .../tables/data/church_slavonic.yml | 0 .../tables/data/ethiopic.yml | 0 .../tables/data/georgian.yml | 0 .../tables/data/hindi.yml | 0 .../tables/data/index.yml | 0 .../tables/data/kazakh.yml | 0 .../tables/data/kyrgyz.yml | 0 .../tables/data/mongolian.yml | 0 .../tables/data/mongolian_mongol_bichig.yml | 0 .../tables/data/russian.yml | 0 .../tables/data/serbian_macedonian.yml | 0 .../tables/data/tajik.yml | 0 .../tables/data/tatar.yml | 0 .../tables/data/turkmen.yml | 0 .../tables/data/ukrainian.yml | 0 .../tables/data/uzbek.yml | 0 {transliterator => scriptshifter}/templates/index.html | 0 .../templates/layout.html | 0 .../templates/navbar.html | 0 .../templates/transliterate.html | 0 {transliterator => scriptshifter}/trans.py | 4 ++-- tests/test01_cfg.py | 6 +++--- tests/test02_transliteration.py | 10 +++++----- transliterator/convert.py | 0 wsgi.py | 2 +- 49 files changed, 36 insertions(+), 36 deletions(-) rename {transliterator => scriptshifter}/__init__.py (100%) rename {transliterator => scriptshifter}/exceptions.py (100%) rename {transliterator => scriptshifter}/hooks/__init__.py (100%) rename {transliterator => scriptshifter}/hooks/test.py (94%) rename {transliterator => scriptshifter}/rest_api.py (95%) rename {transliterator => scriptshifter}/static/milligram.min.css (100%) rename {transliterator => scriptshifter}/static/milligram.min.css.map (100%) rename {transliterator => scriptshifter}/static/normalize.css (100%) rename {transliterator => scriptshifter}/tables/__init__.py (98%) rename {transliterator => scriptshifter}/tables/data/_cyrillic_base.yml (100%) rename {transliterator => scriptshifter}/tables/data/_ignore_base.yml (100%) rename {transliterator => scriptshifter}/tables/data/armenian.yml (100%) rename {transliterator => scriptshifter}/tables/data/asian_cyrillic.yml (100%) rename {transliterator => scriptshifter}/tables/data/azerbaijani.yml (100%) rename {transliterator => scriptshifter}/tables/data/belarusian.yml (100%) rename {transliterator => scriptshifter}/tables/data/bulgarian.yml (100%) rename {transliterator => scriptshifter}/tables/data/chinese.yml (100%) rename {transliterator => scriptshifter}/tables/data/church_slavonic.yml (100%) rename {transliterator => scriptshifter}/tables/data/ethiopic.yml (100%) rename {transliterator => scriptshifter}/tables/data/georgian.yml (100%) rename {transliterator => scriptshifter}/tables/data/hindi.yml (100%) rename {transliterator => scriptshifter}/tables/data/index.yml (100%) rename {transliterator => scriptshifter}/tables/data/kazakh.yml (100%) rename {transliterator => scriptshifter}/tables/data/kyrgyz.yml (100%) rename {transliterator => scriptshifter}/tables/data/mongolian.yml (100%) rename {transliterator => scriptshifter}/tables/data/mongolian_mongol_bichig.yml (100%) rename {transliterator => scriptshifter}/tables/data/russian.yml (100%) rename {transliterator => scriptshifter}/tables/data/serbian_macedonian.yml (100%) rename {transliterator => scriptshifter}/tables/data/tajik.yml (100%) rename {transliterator => scriptshifter}/tables/data/tatar.yml (100%) rename {transliterator => scriptshifter}/tables/data/turkmen.yml (100%) rename {transliterator => scriptshifter}/tables/data/ukrainian.yml (100%) rename {transliterator => scriptshifter}/tables/data/uzbek.yml (100%) rename {transliterator => scriptshifter}/templates/index.html (100%) rename {transliterator => scriptshifter}/templates/layout.html (100%) rename {transliterator => scriptshifter}/templates/navbar.html (100%) rename {transliterator => scriptshifter}/templates/transliterate.html (100%) rename {transliterator => scriptshifter}/trans.py (98%) delete mode 100644 transliterator/convert.py diff --git a/Dockerfile b/Dockerfile index c65f01b..c99b6c8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,13 +3,13 @@ FROM python:3.9-alpine3.15 RUN apk add --no-cache -t buildtools build-base RUN apk add --no-cache linux-headers -ENV _workroot "/usr/local/transliterator/src" +ENV _workroot "/usr/local/scriptshifter/src" WORKDIR ${_workroot} COPY requirements.txt ./ RUN pip install -r requirements.txt COPY entrypoint.sh uwsgi.ini wsgi.py ./ -COPY transliterator ./transliterator/ +COPY scriptshifter ./scriptshifter/ RUN chmod +x ./entrypoint.sh RUN addgroup -S www && adduser -S www -G www diff --git a/NOTES.md b/NOTES.md index 9fade51..43033aa 100644 --- a/NOTES.md +++ b/NOTES.md @@ -3,7 +3,7 @@ ## `.cfg` files The `.cfg` format seems to follow a INI-like syntax that is ad-hoc-parsed by -the Transliterator. +the ScriptShifter. Unicode points are expressed as `U+????` rather than `\x????` of the standard INI syntax. @@ -54,7 +54,7 @@ A (RB): Yes. ## `ReRomanizeRecord.bas` Much of the code deals with MARC records. No need to concern about that since -the new Transliterator is meant to convert text strings to text strings. +the new ScriptShifter is meant to convert text strings to text strings. Q: Is it possible (and desirable) to determine the S2R/R2S direction from user prompt rather than guessing it from the text as the legacy software seems to @@ -248,7 +248,7 @@ HTML or Markdown, so this may need to be taken into account.) Q: It seems like several characters are parsed and added to the text to denote MARC markers. Do we need to deal with these manually as indicators related to the script/language handled, or shall we expect any text string input in the -new Transliterator to be clean from MARC flags? +new ScriptShifter to be clean from MARC flags? A (RB): Most MARC markers are obsolete; but there may be other markers that are not easily transliterated, e.g. BIBFRAME markers. More discussion is needed diff --git a/README.md b/README.md index 1f025f0..1377b65 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# transliterator +# ScriptShifter REST API service to convert non-Latin scripts to Latin, and vice versa. @@ -7,13 +7,13 @@ REST API service to convert non-Latin scripts to Latin, and vice versa. Build container in current dir: ``` -docker build -t transliterator:latest . +docker build -t scriptshifter:latest . ``` Start container: ``` -docker run -e TXL_FLASK_SECRET=changeme -p 8000:8000 transliterator:latest +docker run -e TXL_FLASK_SECRET=changeme -p 8000:8000 scriptshifter:latest ``` For running in development mode, add `-e FLASK_ENV=development` to the options. diff --git a/doc/config.md b/doc/config.md index 05df5e1..4e5e4e2 100644 --- a/doc/config.md +++ b/doc/config.md @@ -1,4 +1,4 @@ -# Transliterator configuration file format +# ScriptShifter configuration file format Language transliteration is made according to set of rules contained in static files. Generally, each file represents one script and one language, but there @@ -6,7 +6,7 @@ may be exception to this rule in cases of multiple languages sharing the same script. Configuration files, also called transliteration tables, are contained in the -[`/transliterator/tables/data`](../transliterator/tables/data) directory. +[`/scriptshifter/tables/data`](../scriptshifter/tables/data) directory. ## Types of configuration files @@ -189,7 +189,7 @@ Each key in this section is one of the predefined hook names and is paired with a list of functions that shall be run when the life cycle point designated for the hook is reached. Each function definition is a list of one or two elements. The first is the function path including the path, relative to the -`transliterator.hooks` package. The second, optional element, is a map of +`scriptshifter.hooks` package. The second, optional element, is a map of key-value pairs provding additional keyword arguments for the function. These arguments are fixed for all the calls to this function made by this hook. @@ -207,7 +207,7 @@ script_to_roman: ``` runs the function `myfn(ctx, x=32, y="hello")` in -`transliterator.hooks.my_module` (`ctx` is always provided by the application) +`scriptshifter.hooks.my_module` (`ctx` is always provided by the application) for the `pre_tx_token` hook. ### `script_to_roman` diff --git a/doc/hooks.md b/doc/hooks.md index 4051c5d..feb81d7 100644 --- a/doc/hooks.md +++ b/doc/hooks.md @@ -1,4 +1,4 @@ -# Transliterator life cycle hooks +# ScriptShifter life cycle hooks This is a guide for language specialists with some Python development skills, or who can partner with Python developers to create new, complex @@ -98,12 +98,12 @@ Hook functions may be defined for each language/script in the corresponding configuration file. See [`config.md`](./config.md) for details. The function name takes the form of `.` and must -correspond to an existing module and function under the `transliterator.hooks` -package. Check the [`rot3.yml`](../transliterator/tables/data/rot3.yml) test +correspond to an existing module and function under the `scriptshifter.hooks` +package. Check the [`rot3.yml`](../scriptshifter/tables/data/rot3.yml) test configuration and the referred functions for a working example. Each hook requires some arguments to be defined in each function associated -with it: `ctx`, an instance of `transliterator.trans.Context` which carries +with it: `ctx`, an instance of `scriptshifter.trans.Context` which carries information about the current scanner status and can be manipulated by the hook function; and `**kw`, optional keyword-only arguments, whose values can be defined in the configuration. @@ -112,7 +112,7 @@ Each function must also return an output that the process is able to handle as expected. the output may instruct the application to make a specific decision after the hook function is executed. Possible return values are defined below for each hook. Some special return values, such as `BREAK` and `CONT`, are -registered as constants under `transliterator.exceptions`. +registered as constants under `scriptshifter.exceptions`. **[TODO]** These hooks are being implemented in a vacuum, without much of a real-world use case. Modifications to these capabilities may change as actual diff --git a/doc/rest_api.md b/doc/rest_api.md index bf497ff..aa71104 100644 --- a/doc/rest_api.md +++ b/doc/rest_api.md @@ -1,4 +1,4 @@ -# Transliterator REST API +# ScriptShifter REST API ## `GET /health` diff --git a/entrypoint.sh b/entrypoint.sh index ab666ef..21106ec 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,8 +1,8 @@ #!/bin/sh export PYTHONPATH=$PYTHONPATH:. -export WEBAPP_PIDFILE="/run/transliterator_webapp.pid" -export FLASK_APP="transliterator.rest_api" +export WEBAPP_PIDFILE="/run/scriptshifter_webapp.pid" +export FLASK_APP="scriptshifter.rest_api" if [ "${TXL_APP_MODE}" == "development" ]; then export FLASK_ENV="development" else diff --git a/transliterator/__init__.py b/scriptshifter/__init__.py similarity index 100% rename from transliterator/__init__.py rename to scriptshifter/__init__.py diff --git a/transliterator/exceptions.py b/scriptshifter/exceptions.py similarity index 100% rename from transliterator/exceptions.py rename to scriptshifter/exceptions.py diff --git a/transliterator/hooks/__init__.py b/scriptshifter/hooks/__init__.py similarity index 100% rename from transliterator/hooks/__init__.py rename to scriptshifter/hooks/__init__.py diff --git a/transliterator/hooks/test.py b/scriptshifter/hooks/test.py similarity index 94% rename from transliterator/hooks/test.py rename to scriptshifter/hooks/test.py index 35ad2bf..ff3a077 100644 --- a/transliterator/hooks/test.py +++ b/scriptshifter/hooks/test.py @@ -1,6 +1,6 @@ import logging -from transliterator.exceptions import CONT +from scriptshifter.exceptions import CONT __doc__ = """ Test hook functions. """ diff --git a/transliterator/rest_api.py b/scriptshifter/rest_api.py similarity index 95% rename from transliterator/rest_api.py rename to scriptshifter/rest_api.py index 3d017d6..2ed528a 100644 --- a/transliterator/rest_api.py +++ b/scriptshifter/rest_api.py @@ -3,8 +3,8 @@ from flask import Flask, Response, jsonify, render_template, request -from transliterator.tables import list_tables, load_table -from transliterator.trans import transliterate +from scriptshifter.tables import list_tables, load_table +from scriptshifter.trans import transliterate def create_app(): diff --git a/transliterator/static/milligram.min.css b/scriptshifter/static/milligram.min.css similarity index 100% rename from transliterator/static/milligram.min.css rename to scriptshifter/static/milligram.min.css diff --git a/transliterator/static/milligram.min.css.map b/scriptshifter/static/milligram.min.css.map similarity index 100% rename from transliterator/static/milligram.min.css.map rename to scriptshifter/static/milligram.min.css.map diff --git a/transliterator/static/normalize.css b/scriptshifter/static/normalize.css similarity index 100% rename from transliterator/static/normalize.css rename to scriptshifter/static/normalize.css diff --git a/transliterator/tables/__init__.py b/scriptshifter/tables/__init__.py similarity index 98% rename from transliterator/tables/__init__.py rename to scriptshifter/tables/__init__.py index 120580e..3b5bff3 100644 --- a/transliterator/tables/__init__.py +++ b/scriptshifter/tables/__init__.py @@ -11,7 +11,7 @@ except ImportError: from yaml import Loader -from transliterator.exceptions import ConfigError +from scriptshifter.exceptions import ConfigError __doc__ = """ @@ -39,7 +39,7 @@ "post_assembly", ) # Package path where hook functions are kept. -HOOK_PKG_PATH = "transliterator.hooks" +HOOK_PKG_PATH = "scriptshifter.hooks" logger = logging.getLogger(__name__) diff --git a/transliterator/tables/data/_cyrillic_base.yml b/scriptshifter/tables/data/_cyrillic_base.yml similarity index 100% rename from transliterator/tables/data/_cyrillic_base.yml rename to scriptshifter/tables/data/_cyrillic_base.yml diff --git a/transliterator/tables/data/_ignore_base.yml b/scriptshifter/tables/data/_ignore_base.yml similarity index 100% rename from transliterator/tables/data/_ignore_base.yml rename to scriptshifter/tables/data/_ignore_base.yml diff --git a/transliterator/tables/data/armenian.yml b/scriptshifter/tables/data/armenian.yml similarity index 100% rename from transliterator/tables/data/armenian.yml rename to scriptshifter/tables/data/armenian.yml diff --git a/transliterator/tables/data/asian_cyrillic.yml b/scriptshifter/tables/data/asian_cyrillic.yml similarity index 100% rename from transliterator/tables/data/asian_cyrillic.yml rename to scriptshifter/tables/data/asian_cyrillic.yml diff --git a/transliterator/tables/data/azerbaijani.yml b/scriptshifter/tables/data/azerbaijani.yml similarity index 100% rename from transliterator/tables/data/azerbaijani.yml rename to scriptshifter/tables/data/azerbaijani.yml diff --git a/transliterator/tables/data/belarusian.yml b/scriptshifter/tables/data/belarusian.yml similarity index 100% rename from transliterator/tables/data/belarusian.yml rename to scriptshifter/tables/data/belarusian.yml diff --git a/transliterator/tables/data/bulgarian.yml b/scriptshifter/tables/data/bulgarian.yml similarity index 100% rename from transliterator/tables/data/bulgarian.yml rename to scriptshifter/tables/data/bulgarian.yml diff --git a/transliterator/tables/data/chinese.yml b/scriptshifter/tables/data/chinese.yml similarity index 100% rename from transliterator/tables/data/chinese.yml rename to scriptshifter/tables/data/chinese.yml diff --git a/transliterator/tables/data/church_slavonic.yml b/scriptshifter/tables/data/church_slavonic.yml similarity index 100% rename from transliterator/tables/data/church_slavonic.yml rename to scriptshifter/tables/data/church_slavonic.yml diff --git a/transliterator/tables/data/ethiopic.yml b/scriptshifter/tables/data/ethiopic.yml similarity index 100% rename from transliterator/tables/data/ethiopic.yml rename to scriptshifter/tables/data/ethiopic.yml diff --git a/transliterator/tables/data/georgian.yml b/scriptshifter/tables/data/georgian.yml similarity index 100% rename from transliterator/tables/data/georgian.yml rename to scriptshifter/tables/data/georgian.yml diff --git a/transliterator/tables/data/hindi.yml b/scriptshifter/tables/data/hindi.yml similarity index 100% rename from transliterator/tables/data/hindi.yml rename to scriptshifter/tables/data/hindi.yml diff --git a/transliterator/tables/data/index.yml b/scriptshifter/tables/data/index.yml similarity index 100% rename from transliterator/tables/data/index.yml rename to scriptshifter/tables/data/index.yml diff --git a/transliterator/tables/data/kazakh.yml b/scriptshifter/tables/data/kazakh.yml similarity index 100% rename from transliterator/tables/data/kazakh.yml rename to scriptshifter/tables/data/kazakh.yml diff --git a/transliterator/tables/data/kyrgyz.yml b/scriptshifter/tables/data/kyrgyz.yml similarity index 100% rename from transliterator/tables/data/kyrgyz.yml rename to scriptshifter/tables/data/kyrgyz.yml diff --git a/transliterator/tables/data/mongolian.yml b/scriptshifter/tables/data/mongolian.yml similarity index 100% rename from transliterator/tables/data/mongolian.yml rename to scriptshifter/tables/data/mongolian.yml diff --git a/transliterator/tables/data/mongolian_mongol_bichig.yml b/scriptshifter/tables/data/mongolian_mongol_bichig.yml similarity index 100% rename from transliterator/tables/data/mongolian_mongol_bichig.yml rename to scriptshifter/tables/data/mongolian_mongol_bichig.yml diff --git a/transliterator/tables/data/russian.yml b/scriptshifter/tables/data/russian.yml similarity index 100% rename from transliterator/tables/data/russian.yml rename to scriptshifter/tables/data/russian.yml diff --git a/transliterator/tables/data/serbian_macedonian.yml b/scriptshifter/tables/data/serbian_macedonian.yml similarity index 100% rename from transliterator/tables/data/serbian_macedonian.yml rename to scriptshifter/tables/data/serbian_macedonian.yml diff --git a/transliterator/tables/data/tajik.yml b/scriptshifter/tables/data/tajik.yml similarity index 100% rename from transliterator/tables/data/tajik.yml rename to scriptshifter/tables/data/tajik.yml diff --git a/transliterator/tables/data/tatar.yml b/scriptshifter/tables/data/tatar.yml similarity index 100% rename from transliterator/tables/data/tatar.yml rename to scriptshifter/tables/data/tatar.yml diff --git a/transliterator/tables/data/turkmen.yml b/scriptshifter/tables/data/turkmen.yml similarity index 100% rename from transliterator/tables/data/turkmen.yml rename to scriptshifter/tables/data/turkmen.yml diff --git a/transliterator/tables/data/ukrainian.yml b/scriptshifter/tables/data/ukrainian.yml similarity index 100% rename from transliterator/tables/data/ukrainian.yml rename to scriptshifter/tables/data/ukrainian.yml diff --git a/transliterator/tables/data/uzbek.yml b/scriptshifter/tables/data/uzbek.yml similarity index 100% rename from transliterator/tables/data/uzbek.yml rename to scriptshifter/tables/data/uzbek.yml diff --git a/transliterator/templates/index.html b/scriptshifter/templates/index.html similarity index 100% rename from transliterator/templates/index.html rename to scriptshifter/templates/index.html diff --git a/transliterator/templates/layout.html b/scriptshifter/templates/layout.html similarity index 100% rename from transliterator/templates/layout.html rename to scriptshifter/templates/layout.html diff --git a/transliterator/templates/navbar.html b/scriptshifter/templates/navbar.html similarity index 100% rename from transliterator/templates/navbar.html rename to scriptshifter/templates/navbar.html diff --git a/transliterator/templates/transliterate.html b/scriptshifter/templates/transliterate.html similarity index 100% rename from transliterator/templates/transliterate.html rename to scriptshifter/templates/transliterate.html diff --git a/transliterator/trans.py b/scriptshifter/trans.py similarity index 98% rename from transliterator/trans.py rename to scriptshifter/trans.py index 3d04a13..5244e29 100644 --- a/transliterator/trans.py +++ b/scriptshifter/trans.py @@ -1,8 +1,8 @@ import logging import re -from transliterator.exceptions import BREAK, CONT -from transliterator.tables import load_table +from scriptshifter.exceptions import BREAK, CONT +from scriptshifter.tables import load_table # Match multiple spaces. diff --git a/tests/test01_cfg.py b/tests/test01_cfg.py index 111bb20..5ae37ab 100644 --- a/tests/test01_cfg.py +++ b/tests/test01_cfg.py @@ -4,7 +4,7 @@ from os import environ from tests import TEST_DATA_DIR -import transliterator.tables +import scriptshifter.tables class TestConfig(TestCase): @@ -12,8 +12,8 @@ class TestConfig(TestCase): def test_ordering(self): environ["TXL_CONFIG_TABLE_DIR"] = TEST_DATA_DIR - reload(transliterator.tables) # Reload new config dir. - from transliterator import tables + reload(scriptshifter.tables) # Reload new config dir. + from scriptshifter import tables tables.list_tables.cache_clear() tables.load_table.cache_clear() diff --git a/tests/test02_transliteration.py b/tests/test02_transliteration.py index 81dccfe..a9c2aa8 100644 --- a/tests/test02_transliteration.py +++ b/tests/test02_transliteration.py @@ -7,8 +7,8 @@ from os import environ, path from tests import TEST_DATA_DIR -from transliterator.trans import transliterate -import transliterator.tables +from scriptshifter.trans import transliterate +import scriptshifter.tables logger = logging.getLogger(__name__) @@ -32,7 +32,7 @@ def sample_s2r(self): This function name won't start with `test_` otherwise will be automatically run without parameters. """ - config = transliterator.tables.load_table(self.tbl) + config = scriptshifter.tables.load_table(self.tbl) if "script_to_roman" in config: txl = transliterate(self.script, self.tbl) self.assertEqual(txl, self.roman) @@ -44,7 +44,7 @@ def sample_r2s(self): This function name won't start with `test_` otherwise will be automatically run without parameters. """ - config = transliterator.tables.load_table(self.tbl) + config = scriptshifter.tables.load_table(self.tbl) if "roman_to_script" in config: txl = transliterate(self.roman, self.tbl, r2s=True) self.assertEqual(txl, self.script) @@ -76,6 +76,6 @@ def make_suite(): if "TXL_CONFIG_TABLE_DIR" in environ: del environ["TXL_CONFIG_TABLE_DIR"] - reload(transliterator.tables) + reload(scriptshifter.tables) TextTestRunner().run(make_suite()) diff --git a/transliterator/convert.py b/transliterator/convert.py deleted file mode 100644 index e69de29..0000000 diff --git a/wsgi.py b/wsgi.py index c98b301..2a0bc68 100644 --- a/wsgi.py +++ b/wsgi.py @@ -1,4 +1,4 @@ -from transliterator.rest_api import app +from scriptshifter.rest_api import app if __name__ == "__main__":